필터 지우기
필터 지우기

Extraction of the region of interest in MATLAB

조회 수: 3 (최근 30일)
anshumala rakesh
anshumala rakesh 2018년 10월 5일
댓글: anshumala rakesh 2018년 10월 5일
I have this binary image as my input and I want to extract the region marked in red automatically without manually providing any coordinates Any help will be appreciated
  댓글 수: 3
anshumala rakesh
anshumala rakesh 2018년 10월 5일
Actually I was given a gray-scale image in .TIF format and I had to extract this A type region.so I binarized it and since it was the largest area so I extracted it using the bwareafilt but now I have to extract that particular region
anshumala rakesh
anshumala rakesh 2018년 10월 5일
This is the original image which I have converted in .BMP for uploading purpose

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

채택된 답변

JSC
JSC 2018년 10월 5일
Here is some code which should work for this task:
Read in the image:
Image=imread('input.bmp');
figure
imshow(Image)
Get the red and green channel of the rgb-image:
RedChannel=Image(:,:,1);
GreenChannel=Image(:,:,2);
Convert red areas to 1 and others to 0:
Image_BW = (RedChannel>200).* (GreenChannel<100);
figure(1)
clf
imshow(Image_BW)
Get the boundaries:
B=bwboundaries(Image_BW);
Get and plot inner boundary
Bound=B{2};
hold on
plot(Bound(:,2),Bound(:,1),'g-')
Get minimal and maximal x-position of roi
min_x=min(Bound(:,2));
max_x=max(Bound(:,2));
Image2=zeros(size(Image));
%loop over columns intersecting roi
for i=min_x:max_x
%get logical vector with 1s for roi-boundary-pixels in ith line
x=Bound(:,2)==i;
%get minimal and maximal y-value of roi in ith column
min_y=min(Bound(x,1));
max_y=max(Bound(x,1));
%write ith column of roi to Image2
Image2(min_y:max_y,i,:)=Image(min_y:max_y,i,:);
end
Plot the result
figure(2)
imshow(Image2);
  댓글 수: 5
JSC
JSC 2018년 10월 5일
So is the answer what you imagined? Can you run the code for the bmp-image?
anshumala rakesh
anshumala rakesh 2018년 10월 5일
No not properly

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by