Problem with matrix calculation

2 次查看(过去 30 天)
Thomas Koelen
Thomas Koelen 2015-4-7
编辑: Matt J 2015-4-7
I have the following line of code that represents the inverse function of:
a+b*(100*10^-x)^c
this is the x:
x=double(gssq.(strcat(sheetNamesOECF{rgby2d},num2str(rgby2d2)))(:,:,1))/255
0.1098 0.1137 0.1137 0.1137 0.1137 0.1137 0.1098 0.1098 0.1137
0.1098 0.1176 0.1137 0.1098 0.1098 0.1098 0.1098 0.1098 0.1098
0.1137 0.1176 0.1137 0.1098 0.1137 0.1137 0.1176 0.1137 0.1137
0.1098 0.1137 0.1098 0.1098 0.1098 0.1098 0.1137 0.1098 0.1098
0.1137 0.1098 0.1059 0.1098 0.1137 0.1098 0.1098 0.1098 0.1098
this is the inverse function:
-log10(((coeffr(1,1)-double(x)/100^coeffr(1,3)/coeffr(1,2))^(1/coeffr(1,3))))
now, when I fill it in like this:
-log10(((coeffr(1,1)-double(0.1)/100^coeffr(1,3)/coeffr(1,2))^(1/coeffr(1,3))))
I get:
2.2059 + 0.7575i
but when I fill in the matrix instead of the constant I get values like this:
1.1654 + 0.7560i
these are way smaller than what they are supposed to be.
does anyone know why filling in the same value gives me different results?
Kind regards,
Thomas Koelen
  2 个评论
Joep
Joep 2015-4-7
double(x) and double(0.11) are not equal. double(x) is in this cames almost 9*0.11. That's why the number is 2 times as high.
The second why use a second double(x)? the numbers are already double. If you want to use the first number of x. Use x(1) or x(1,1).
The third why you using double(...)/255 you can use instead of these im2double, does exact the same but the deference is this function already devides it by 255.
The forth point is are you sure you not reflecting the RGB coefficients with these coefficients? otherwise you should multiply this coefficients by 255.
Thomas Koelen
Thomas Koelen 2015-4-7
1. I don't understand why double x would be 9*0.11, could you explain yourself further?
2. This is my mistake, I just replaced the 0.1 with x here, in the code it's actually x.
3. Because I didn't know this function earlier on and already created a structute that has all the seperate channels.
4. because it is a normalised pixel value to calculate the OECF curve, so the pixels go from 0-1.
Kind regards

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2015-4-7
编辑:Matt J 2015-4-7
Are you sure the cube root of -1 is also -1? This command thinks so
>> nthroot(-1,3)
ans =
-1
but this command has a different opinion,
>> (-1)^(1/3)
ans =
0.5000 + 0.8660i

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by