how do I get binary data image with the save button on the guide?

5 vues (au cours des 30 derniers jours)
olivio gusmao
olivio gusmao le 17 Mai 2020
Commenté : Image Analyst le 20 Mai 2020
I am segmenting and saving images that have been segmented. The image was successfully saved with jpg type but I don't know how to save binary data from a segmented image.
is there a solution for this?
global frame
[name_file_save, path_save]=uiputfile ({'*.jpg','JPEG Image (*.jpg)';},'save citra');
if isequal(name_file_save,0) || isequal(path_save,0)
msgbox('Image is saved', 'Foto_Editor')
else
F=getframe(handles.axes2);
img=frame2im(F);
imwrite(img, fullfile(path_save,nama_file_save),'jpg');
end
axes(handles.axes2)
  1 commentaire
Walter Roberson
Walter Roberson le 17 Mai 2020
Saving segmentation information as .jpg is not a good idea. .jpg blurs sharp lines, and segmentation information is all sharp lines.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 17 Mai 2020
Modifié(e) : Image Analyst le 17 Mai 2020
You don't need to use getframe(). That just saves a screenshot which will not even be the same size as the image you're hoping to save.
A segmented image is a binary / logical variable. You can save it with imwrite() if you cast to uint8. You might want to scale to 255 also.
% Make a uint8 image with values of 0 and 255 (so we can see it in the File Explorer thumbnail).
uint8Image = 255 * uint8(binaryImage); % binaryImage is your segmented image.
% Get base file name. Discard any extension they may have entered, like jpg.
[f, baseFileNameNoExt, ext] = fileparts(name_file_save);
% Construct full file name.
fullFileName = fullfile(path_save, [baseFileNameNoExt, '.png']); % NEVER use jpg for image analysis. Use PNG.
% Now do the actual save of the segmented image to disk as a PNG format image.
imwrite(uint8Image, fullFileName); % Save PNG image.
  7 commentaires
Walter Roberson
Walter Roberson le 20 Mai 2020
data_that_is_0_and_1s = double(binaryImage);
Image Analyst
Image Analyst le 20 Mai 2020
binaryImage = imbinarize(grayScaleImage);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by