Is there any way to do an operator on a specific region

조회 수: 2 (최근 30일)
sara
sara 2014년 9월 30일
답변: Iain 2014년 9월 30일
Is there any way to do an operator on a specific region ?? for example I want to do imfill just on the Lower left quadrant of the page... I search and find blockproce but I could not do this for Lower left quadrant of the page??? thanks

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 9월 30일
Something like this would work.
[r,c]=size(BWImage);
rHalf=round(r/2);
cHalf=round(c/2);
lowerLeftQuadrant=BWImage(rHalf:r,1:cHalf);
lowerLeftQuadrant=imfill(lowerLeftQuadrant);
BWImage(rHalf:r,1:cHalf)= lowerLeftQuadrant;
Note that You can make the code shorter by replacing the last three lines of code as follow:
BWImage(rHalf:r,1:cHalf)= imfill( BWImage(rHalf:r,1:cHalf) );

추가 답변 (2개)

Anand
Anand 2014년 9월 30일
What you're looking for is the roifilt2 function.

Iain
Iain 2014년 9월 30일
A simple way is to simply chop it off:
% (Tune the numbers for what you need)
LowerLeftquad = my_image(74:end,1:30); % assuming a single frame of black & white.
LowerLeftquad = my_image(74:end,1:30,:); % assuming a single colour frame or many black & white.
Do what you want:
LowerLeftquad = imfill(LowerLeftquad);
And stick it back:
my_image(74:end,1:30) = LowerLeftquad;

Community Treasure Hunt

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

Start Hunting!

Translated by