How do I save the image for the last part code?

1 回表示 (過去 30 日間)
Dayangku Nur Faizah Pengiran Mohamad
Dayangku Nur Faizah Pengiran Mohamad 2022 年 12 月 4 日
コメント済み: DGM 2022 年 12 月 6 日
Here's my code:
%%Step 3 : Calculation of area of the abnormality region Step
%To read the FCM input image
%I3=imread('redfcmgrayb245_78_864_rap00001.jpg');
I3=imread('greenfcmgrayb245_72_864_rap00001.jpg');
%To convert the input image to pure black and white to highlight the abnormality region and its background
%threshold=graythres(I3);
threshold=graythresh(I3);
bw=im2bw(I3,threshold);
%To display the pure black and white of the input image
imshow(bw);
%To save the display of pure black and white input image
%imwrite(bw,'redthresfcmgrayb245_78_864_rap00001.jpg');
imwrite(bw,'greenthresfcmgrayb245_72_864_rap00001.jpg');
%To remove image noise which consists of extraneous pixels in the objects
%of interest (abnormality region) in order to obtain accurate calculation
bw=bwareaopen(bw,30);
se=strel('disk',2);
bw=imclose(bw,se);
imshow(bw);
%imwrite(bw,'redopenthresfcmgrayb245_78_864_rap00001.jpg');
imwrite(bw,'greenopenthresfcmgrayb245_72_864_rap00001.jpg');
%To trace perimeter of an object
BWP1=bwperim(bw);
%To fill the perimeter with white colour pixels while the other
%non-boundary objects with black clour pixels
BWF1=imfill(BWP1);
%To display the boundary of the target object which is the abnormality
%region
%imwrite(BWF1,'redimfillopenthresfcmgrayb245_78_864_rap00001.jpg');
imwrite(BWF1,'greenimfillopenthresfcmgrayb245_72_864_rap00001.jpg');
%To calculate the area of the abnormality region
D1=regionprops(BWF1,'area');
imwrite(D1,'greenareaimfillopenthresfcmgrayb245_72_864_rap00001.jpg');
the code last one 'imwrite(D1,'greenareaimfillopenthresfcmgrayb245_72_864_rap00001.jpg');' got error
and the error says like this:-
>> Step3
Error using imwrite (line 442)
Expected DATA to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was struct.
Error in Step3 (line 41)
imwrite(D1,'greenareaimfillopenthresfcmgrayb245_72_864_rap00001.jpg');
why its show error? and how can I save the image for D1=regionprops(BWF1,'area'); ?

採用された回答

DGM
DGM 2022 年 12 月 4 日
You don't. The output of regionprops() is a struct containing the specified object properties. It doesn't even make conceptual sense to save it as an image. It's not an image in form or concept.
See regionprops().
  2 件のコメント
Dayangku Nur Faizah Pengiran Mohamad
Dayangku Nur Faizah Pengiran Mohamad 2022 年 12 月 4 日
Ok noted. But I want to ask more.
How could I segment the boundary of the abnormality after the code
'BWF1=imfill(BWP1);' ?
Because the result I get not the boundary of the region abnormality, but the area of the abnormality.
Is this the correct code for to get the boundary of the region abnormality?
'I99=imread('cropgreencentroidimfillopenthresfcmgrayb245_72_864_rap00001.jpg');
Segout=I99;
Segout(BWP1)=uint8*255;
figure,imshow(Segout),title('boundary');'
DGM
DGM 2022 年 12 月 6 日
I don't know what any of these results are, since I don't have the source images. If you want the object boundaries, you may be able to use one of the following

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by