Need help in pixel count!
이전 댓글 표시
Hi everybody! I'm struggling to get this one solved.
I have a binary image(640x480) full of 'Salt and Pepper' noise, and I need to count the pixels that are inside a imaginary square with dimensions 100x100, rotated 30º. The upper left pixel of the square (corner) has to be lying in the pixel (200,100) of the image.
I think the best way to solve this is to create a mask with the square rotated and then apply it to the image.
What would be the best way to get it done? I dont get how I guarantee that the upper left corner of the square would be in the pixel (200,300). I need to get a new image with the same size of the original with the square in the right position. Do you have any ideas to solve this?
답변 (2개)
Sean de Wolski
2012년 3월 30일
0 개 추천
Do you want the upper corner at 200,300 or the lefter corner at 200,300. Looking at the image I can't tell.
Either way, you could use the second output from max(bw(:)) on your mask image and sub2ind() to find row/col coordinates. This will be the index of the first maximizer it finds, guaranteed to be a corner and guaranteed to be 1 in an binary image. Whether it's the top corner or the left corner will depend on whether you transpose the mask first.
댓글 수: 2
Walter Roberson
2012년 3월 30일
"lefter" ?
Sean de Wolski
2012년 3월 30일
you got the gist right? ;)
I guess I should apply the Maine-accent
that vertex is leftah than the uppah one!
Rui Trovisco
2012년 3월 31일
0 개 추천
댓글 수: 1
Image Analyst
2012년 3월 31일
I'd guess it was via poly2mask(), thresholding, regionprops, then doing hist([measurements.Area], nBins). Once you have the corner coords, it's basically 4 key lines of code (more if you add comments, display images, print out results, etc.)
카테고리
도움말 센터 및 File Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!