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!