How to draw rectangles along the tampered region of an image ?

조회 수: 2 (최근 30일)
Anushka
Anushka 2015년 2월 8일
답변: Image Analyst 2015년 2월 8일
I have already determined the blocks of an image which are tampered.I want to draw a box over around this blocks and show the same in original image.Can any one please suggest any method for the same.
for i=1:64
if(abs(H(i)-Hm3(i))>1)
imshow(Block0(:,:,i); %tampered block i
[x]=FirstPositionBlock(i,:); %coordinate values of the first pixel of tampered block
end
end
If J is the original image how can i get the box drawn on the image corresponding to the tempered blocks of the image.

채택된 답변

Image Analyst
Image Analyst 2015년 2월 8일
Use rectangle():
rectangle('Position', [x(1), x(2), 32, 32]);

추가 답변 (2개)

Erik S.
Erik S. 2015년 2월 8일
Hi You can use the function
annotation('rectangle',[x y w h])
  댓글 수: 1
Anushka
Anushka 2015년 2월 8일
Thank you for your response.
I used the statement as you said but it showed the error
"Error using annotation (line 129) position values must be between 0 and 1"
The following was what I gave in my program
annotation('rectangle',[x(1) x(2) x(1)+32 x(2)+32]);

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


Erik S.
Erik S. 2015년 2월 8일
Hi, I just saw in the documentation that the inputs should be normalized. Try to divide x(1) width image width and x(2) with image height, same for rectangle width and height.
  댓글 수: 3
Erik S.
Erik S. 2015년 2월 8일
Hi,
Can you upload the file please and state the coordinates where you want the rectangle?
Anushka
Anushka 2015년 2월 8일
I used
shapeInserter = vision.ShapeInserter;
f=int32(x(1));
g=int32(x(2));
rectangle = [g f 32 32];
J1 = step(shapeInserter, J1, rectangle);
and got small small rectangles around each block not an entire rectangle.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by