How to save image that used AlphaData function?

조회 수: 4 (최근 30일)
athirahlan
athirahlan 2019년 3월 13일
댓글: Walter Roberson 2019년 3월 18일
I am using the transparency on watershed,
Lrgb=label2rgb(L,'jet','w','shuffle');
imshow(Lrgb), title('Colored Watershed Label Matrix (Lrgb)')
imshow(I)
hold on
himage=imshow(Lrgb);
himage.AlphaData=0.3;
title('Lrgb Superimposed Transparently on Original Image')
imwrite(himage,'newWAimage.png','PNG');
I want to save the superimposed image using imwrite since i need my image the same size as the original images but "matlab.graphics.primitive.Image." error occurs.
I did use saveas function however the output size image is different than the original image.
Is there any other way to save the superimposed image? Do I need to change the transparency code?
  댓글 수: 3
athirahlan
athirahlan 2019년 3월 13일
Is it using this code?
imagesc(peaks)
alpha color
alpha scaled
will it effect this code?
himage.AlphaData=0.3
Walter Roberson
Walter Roberson 2019년 3월 13일
Yes, setting himage.AlphaData=0.3 will write over the effects of alpha color

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2019년 3월 13일
Did you try getframe()?
  댓글 수: 9
athirahlan
athirahlan 2019년 3월 18일
I'm able to get the image using export_fig.
When using
Lrgb=label2rgb(L,'jet','w','shuffle');
imshow(Lrgb), title('Colored Watershed Label Matrix (Lrgb)')
imshow(I)
[nr, nc, np] = size(Lrgb);
AD = 0.3 * ones(nr, nc);
imwrite(Lrgb, 'NewAImage.png', 'AlphaData', AD);
it produces this error
%Error using writepng>CheckTextItem (line 378)
%Text chunk must be a string.
%Error in writepng (line 258)
% item = CheckTextItem(unmatched.(param_name));
%Error in imwrite (line 472)
% feval(fmt_s.write, data, map, filename, paramPairs{:});
%Error in Watershed_Algorithm (line 114)
%imwrite(Lrgb,'NewAImage.png','AlphaData',AD);
Walter Roberson
Walter Roberson 2019년 3월 18일
imwrite(Lrgb, 'NewAImage.png', 'Alpha', AD);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by