saving coloured image in gui

hiii all!!' i was trying to save an image in tif format after doing maximum intensity projection!!whenever m saving the image stored is in grey scale...my original image colour is green....can anyone give me a solution!!thanks in advance

2 comentarios

Geoff Hayes
Geoff Hayes el 28 de Jul. de 2017
ash - please show the code that you have written to save the image.
ash fairy
ash fairy el 29 de Jul. de 2017
save=newfile('*.tif','SAVE FILE');
imwrite(new,save,'WriteMode','append');

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 28 de Jul. de 2017
Editada: Image Analyst el 28 de Jul. de 2017

0 votos

Are you SURE? Have you passed the image you're passing to imwrite() into the size() function and seen what it says?
[rows, columns, numberOfColorChannels] = size(yourImage) % No semicolon
whos yourImage
What gets reported to the command line for numberOfColorChannels and the data type? If it's 1 instead of 3, then it's gray scale, NOT color. If it's 3, it should save as color, if it's uint8.

3 comentarios

Image Analyst
Image Analyst el 29 de Jul. de 2017
Regarding your code:
save=newfile('*.tif','SAVE FILE');
imwrite(new,save,'WriteMode','append');
Do not use save as the name of your variable. It is the name of an important build in function, which you just (temporarily) destroyed.
Also, please answer my original questions!
ash fairy
ash fairy el 29 de Jul. de 2017
hi, this is my original code axes(handles.axes1); myimage=getimage; saveeeee=uiputfile('*.tif','SAVe'); A=get(hObject,'Value') if A==1 z = zeros(256, 1); ramP = (0:255)' / 255; cmaP = [z, ramP, z];
myimage=ind2rgb(im2uint8(myimage),colormap(cmaP));
imwrite(myimage,saveeeee)
now the file gets saved as green color , but the thing is i want to save my file as 16bit green color(im2uint16 did not work right). currently when i save the file its rgb file. my goal is to get a 16bit color image so that i can read it into imagej
Image Analyst
Image Analyst el 29 de Jul. de 2017
Ash fairy, you need to make a full size colormap, then you need to do this:
rgbImage = ind2rgb(imageInAxes, colormap(cmap));
rgbImage16 = im2uint16(rgbImage);
See this full demo code:
% Initialization
gray8 = imread('cameraman.tif');
gray16 = im2uint16(gray8);
subplot(1, 3, 1);
hAxis = imshow(gray16);
whos gray16
% OK, let's start.
imageInAxes = getimage(hAxis);
whos imageInAxes % Should be uint16.
% Create green color map.
maxGL = double(intmax(class(gray16)))
z = zeros(maxGL + 1, 1);
ramp = (0 : maxGL)' / maxGL;
cmap = [z, ramp, z];
% Convert gray scale 16 bit image to color using colormap
rgbImage = ind2rgb(imageInAxes, colormap(cmap));
whos rgbImage
% Right now rgbImage is double in the range 0-1.
% Convert to uint16 in the range 0-65535
rgbImage16 = im2uint16(rgbImage);
subplot(1, 3, 2);
imshow(rgbImage16);
whos rgbImage
% Ask user to save the image.
[baseFileName, folder] = uiputfile('*.tif','Save the image?');
fullFileName = fullfile(folder, baseFileName)
imwrite(rgbImage16, fullFileName)
% Recall it from disk to check that it looks normal
recalledImage = imread(fullFileName);
subplot(1, 3, 3);
imshow(recalledImage);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Jul. de 2017

Comentada:

el 29 de Jul. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by