How do I save the image for the last part code?
1 次查看(过去 30 天)
显示 更早的评论
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'); ?
0 个评论
采纳的回答
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.
2 个评论
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!