Is there any possible to save the logical image in png?
3 ビュー (過去 30 日間)
古いコメントを表示
Dayangku Nur Faizah Pengiran Mohamad
2023 年 11 月 20 日
回答済み: Dyuman Joshi
2023 年 11 月 21 日
I want to save my image logical as .png. But I got uint8 datatype after save it.
Is it possible to save an image in logical format png?
7 件のコメント
Walter Roberson
2023 年 11 月 21 日
Change
z=imwrite(logical(mask(randi(2, 512,512)-1)),'maskre8.jpg');
to
imwrite(randi([0 1], 512, 512, 'logical'), 'maskre8.png')
Note that JPEG has no possibility of storing images as logical.
採用された回答
Dyuman Joshi
2023 年 11 月 21 日
The variable mask() is already a logical array. You don't need to convert it to logical().
Just write it as a PNG image -
fontSize = 16;
I=imread('rescale8.jpg');
subplot(1, 2, 1);
imshow(I, []);
axis('on', 'image');
%caption = sprintf('Original Image : "%s"', I);
drawnow;
hp = impixelinfo();
hFig1 = gcf;
hFig1.Units = 'Normalized';
hFig1.WindowState = 'maximized';
hFig1.Name = 'Demo by Image Analyst';
% Mask to find the lesion.
hsvImage = rgb2hsv(I);
mask = hsvImage(:,:,2) > 0.3;
% Fill holes.
mask = imfill(mask, 'holes');
class(mask)
% Display the test image full size.
subplot(1, 2, 2);
imshow(mask, []);
axis('on', 'image')
%% Write mask() as a png image
imwrite(mask, 'maskre8.png')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!