Sampling a binary image with a matrix.
이전 댓글 표시
I am looking to sample a binary matrix with a smaller matrix. For example, take a 100x100 "image" binary matrix and pass a 5*10 window centered on each pixel. Would it then be possible to tag certain spots in that frame I'm passing over the image and mark where "1's" occur?
For example, if the frame passes over a '1' in the image I want to look at spots (2,5) and (4,1) and see if there is a pixel that is also a 1.
댓글 수: 8
Geoff
2012년 5월 30일
Do you mean you want to know, for each window position, whether there is a 1 in the main image anywhere within the window (or at selected positions in the window)? You could do that with the function conv2().
Ryan
2012년 5월 30일
Walter Roberson
2012년 5월 30일
conv2() sounds like a good strategy to me as well. Unfortunately, it isn't possible to center a 5 x 10 window over a pixel (to center, the window needs to be odd width and odd height)
Ryan
2012년 5월 30일
Walter Roberson
2012년 5월 30일
Is the (2,5) test independent of the (4,1) test, or do you only want to know when both are present, or do you want to do something different depending on which combination is present?
Ryan
2012년 5월 30일
Geoff
2012년 5월 30일
Is this correct? Let's for a moment assume that you can centre a 5x10 window on a pixel. I'll arbitrarily choose the co-ordinate (3,5) as the 'centre'. What you're asking is if there is a 1 at position (2,5) (the pixel immediately above) and/or (4,1) (the pixel immediately down and 3 places to the left). So in general I would compute two subimages slightly smaller than your large one, and offset one of them, then combine with AND. No convolution required.
Ryan
2012년 5월 31일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!