필터 지우기
필터 지우기

how can i obtain the final result after roipoly?

조회 수: 4 (최근 30일)
mmm ssss
mmm ssss 2012년 1월 18일
hello
i have agrayscale image
i want to extract my target roi
so i wrote this
m=imread(.....); BW=roipoly(m);
after that how can i obtain the roi filling with grayscale ? i mean how can i make benefit of the polygon that i obtained in BW to get my roi as agrayscale?
thanks

채택된 답변

David Young
David Young 2012년 1월 18일
If you want to fill the polygon with interpolated grayscale, have a look at roifill.
If you want to have an image that only shows the original grayscale within the polygon, you can use
mnew = m .* cast(BW, class(m));
EDIT Added in response to comment
If you wish to extract the part of the image containing the region, you can do it like this:
BWprops = regionprops(BW, 'BoundingBox');
smallim = imcrop(mnew, BWprops.BoundingBox);
You can then position smallim in the figure, or copy it into the centre of a larger array.
  댓글 수: 7
David Young
David Young 2012년 1월 19일
You can find the CoG of the ROI using the 'Centroid' option in regionprops. You could get both the bounding box and the centroid in the same call to regionprops.
You can copy the small region into the middle of a larger array by assigning it to a particular range of indices, as in
bigarray(rowstart:rowend, colstart:colend) = smallarray;
The problem is then working out values for rowstart etc., but you should find that reasonably straightforward.
Alternatively, you can use padarray to put a border of zeros round the small image.
mmm ssss
mmm ssss 2012년 1월 19일
You can find the CoG of the ROI using the 'Centroid' option in regionprops. You could get both the bounding box and the centroid in the same call to regionprops.
this is done by :
bw = imread('text.png');
L = bwlabel(bw);
s = regionprops(L, 'centroid','Boundingbox');
now what do you mean by this:
You can copy the small region into the middle of a larger array by assigning it to a particular range of indices, as in
bigarray(rowstart:rowend, colstart:colend) = smallarray;
The problem is then working out values for rowstart etc., but you should find that reasonably straightforward.
Alternatively, you can use padarray to put a border of zeros round the small image.
in codes how this can be implemented?

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by