image processing - my maiden post: Having trouble with ind2rgb function in matlab -


a breif disclaimer: self-taught programmer, , officially first stack overflow post, try , patient.

i have 250x250 probability distribution(pdf) matrix (values ranging 0 1) turn true-color (250x250x3) matrix can save series of these matrices , display them movie or save them rgb image. question two-fold:

first, if use:

cmp=jet; img=ind2rgb(pdf,cmp); 

whereas imagesc(pdf) returns proper heat map figure expect, img ends being blue image, img(:,:,3)=(some value<1) , (img(:,:,1:2)==0. grateful if explain why ind2rgb() isn't (scaling?) same way imagesc() is, , how go fixing that.

additionally:

i know contour() , imagesc() helpful functions displaying these indexed values in matlab figure window, there way save matlab figure true-color image without figure axis?

an answer either or both of these questions appreciated.

colin

ind2rg doesn't scale image, maps colormap. have scale image yourself. also, you'll need specify size of colormap. here's example:

pdf = rand(100,100); % fake data pdfscaled = uint8(256*pdf); % scale data cmp = jet(256); % 256 element colormap img = ind2rgb(pdfscaled,cmp);  subplot(2,1,1) imagesc(pdf) title('indexed image') subplot(2,1,2) image(img)  title('rgb image') 

the resulting plot looks this:

indexed , rgb images

as second questions, getframe , imwrite can used save image displayed in axis. example:

figure imagesc(spiral(10)) frame = getframe(); imwrite(frame.cdata, 'frame.png') 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -