interp3 RGB - temperature
Show older comments
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
Accepted Answer
More Answers (2)
mortain Antonio
on 4 Apr 2011
2 Comments
the cyclist
on 5 Apr 2011
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
on 5 Apr 2011
mortain Antonio
on 5 Apr 2011
1 Comment
the cyclist
on 5 Apr 2011
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.)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!