1
votes

I'm looking to create an intensity matrix in Matlab from an intensity image plot (saved as a jpeg (RGB) file) that was made using what appears to be the jet colormap from Matlab. I am essentially trying to reverse engineer the numerical data from the plot. The original image along with the color bar is linked (I do not have enough reputation to insert images).

http://i.imgur.com/BmryO6W.png

I initially thought this could be done with the rgb2gray command, but it produces the following image with the jet colormap applied which does not match the original image.

http://i.imgur.com/RlBei2z.png

As far as I can tell, the only route available from here is to try matching the RGB value for each pixel to a value in the colormap lookup table. Any suggestions on if this the fastest approach?

1

1 Answers

0
votes

It looks like your method using rgb2gray is almost working, apart from the scale. Because the colormap is scaled automatically to the contents of your plot, I think you will have to re-scale it manually (unless you can automatically detect the tick labels on the colorbar). You can do this using the following formula:

% Some random data like yours
x = rand(1000) * 256;

% Scale data to fit your range
xRange = [min(x(:)) max(x(:))];
scaleRange = [-10 10];
y = (x - xRange(1)) * diff(scaleRange) / diff(xRange) + scaleRange(1);

You can check the operation's success with

>> [min(y(:)) max(y(:))]

ans =

   -10    10