필터 지우기
필터 지우기

imfreehand or imrect -- snap to pixels while drawing

조회 수: 4 (최근 30일)
Rafael J.
Rafael J. 2013년 5월 3일
편집: Pieter 2016년 10월 26일
Is there a way to force the drawing of the shape to snap to the pixels of the image? Currently I have to use imshow with 'InitialMagnification', 100 in order to avoid non-integer pixel values for the position of the imrect.
Also, is there a way to easily acquire the area inside imfreehand? I can do it easily with imrect but with non-rectangular objects it is significantly more difficult.
Thanks in advance
  댓글 수: 1
Ahmed Madani
Ahmed Madani 2015년 12월 10일
I am trying to do the same thing but could't, any help please ?

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

답변 (2개)

Sean de Wolski
Sean de Wolski 2013년 5월 3일
You can do this using the setConstrainedPosition() method of the object.
How are you getting the area for the rectangle? For a freehand there are two things you could do:
  1. Ccreate a mask (using the creatMask method) and get the area of this using bwarea
  2. Use the polyarea function to get the area given the vertices.
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2013년 5월 3일
round()
:)
Image Analyst
Image Analyst 2013년 5월 3일
That's after it's been drawn. I know of no way to have it "go around the edges of pixels" of a highly magnified image while you're drawing, so you're stuck with having to round the returned coordinates afterwards.

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


Pieter
Pieter 2016년 10월 26일
편집: Pieter 2016년 10월 26일
I know this is an old thread but very relevant to me. I would like to have a dragged imrect snap to pixels but have no clue on how to do it? Another solution would be to have the snapping when the mouse button is released after dragging the ROI. Has someone some could he/she would like to share? Thx

Community Treasure Hunt

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

Start Hunting!

Translated by