interp3 RGB - temperature
古いコメントを表示
Hello,
I would like to write a piece of code which takes the RGB values from a picture and change them in temperature.
I have a calibration file which has for each RGB a temperature. I wanted to use the interp3 to start from the calibration file and go to the new picture.
THe function interp3 gives me an error when I use it, since it says that V (in my case temperature) should be a 3D matrix.
PLease, would you mind helping me or addressing in a different direction.
Thank you very much
Antonio
I attacch my piece of code
%calRGB.txt contains 4 columns: R,G,B,temperature (calibration file)
load calRGB.txt
%RGB_f.dat contains 5 columns, x, y, R, G, B of the picture (2d picture)
load RGB_f.dat
RGB=RGB_f;
x=RGB(:,1);
y=RGB(:,2);
v=RGB(:,3);
w=RGB(:,4);
z=RGB(:,5);
%initialize temp
temp=x;
temp(:)=0;
%interpolation
for ii = 1:length(x(:,1))
temp(ii)=interp3(calRGB(:,1), calRGB(:,2),calRGB(:,3),calRGB(:,4), v(ii),w(ii),z(ii));
end
%write the temperature for each point on a variable
output=RGB_f;
output(:,:,:)=0;
for ii = 1:length(x(:,1))
output(ii,:)=[x(ii), y(ii) ,temp(ii)];
end
採用された回答
その他の回答 (2 件)
mortain Antonio
2011 年 4 月 4 日
2 件のコメント
the cyclist
2011 年 4 月 5 日
Almost certainly the NaNs are value that lie outside the "convex hull" (the outer boundary) of your known values. You can test this by temporarily choosing "nearest" as the interpolation method for TriScatteredInterp, and seeing if the NaNs go away. My guess is they will.
You can use the CONVHULL command to plot out what your convex hull looks like.
Are you able to extend your grid of known points, to capture those points? If not, you can't really interpolate between.
[Also, you should accept this answer if it was helpful, so that others with a similar question can get the benefit of the answer in the future.]
mortain Antonio
2011 年 4 月 5 日
mortain Antonio
2011 年 4 月 5 日
1 件のコメント
the cyclist
2011 年 4 月 5 日
When you use the nearest method, you need to enclose that in single quotes: 'nearest'.
The command is lower-case: convhull. "help convhull" for details. (I was using the unfortunate convention from the documentation, in which commands are written in all caps even though that is not how you type them.)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!