이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
move a 3*3 window on a binary image
조회 수: 3 (최근 30일)
이전 댓글 표시
hi I have a 3*3 window and a binary image..I want to move this window on this image... how can do this? thanks
댓글 수: 1
답변 (2개)
Image Analyst
2014년 9월 3일
Try imfilter(), conv2(), or nlfilter(), or possibly blockproc(). That's about all I can say until you provide more information.
댓글 수: 17
Image Analyst
2014년 9월 3일
So, if in your 3 by 3 window, any of the values in the left most column match any of the values in the right-most column, regardless if they are in the same row or different rows, fill the entire 3by3 window in the output location with the value that matches? What if there are 2 matches, like the (1,1) pixel matches the (2,3) pixels with value 1(true) and the (2,1) pixels matches the (3,3) pixel with value 0? Is the 3x3 output square set to 0 or 1?
atefeh gh
2014년 9월 3일
yes you are right Image Analyst I should think about this. I will come back very soon and I hope you will help me to solve this.
Image Analyst
2014년 9월 3일
What's the overall intent anyway? What do you really want to do, such that you devised this unusual algorithm for? Maybe there's a way to get what you want without doing this unusual thing, which I think will probably be done best with nlfilter().
atefeh gh
2014년 9월 3일
Image Analyst I want to segment the lung to two region: lungs(zero value) and no lung(one value). when I use a segmentation method there are some bronchiole and nodule parts inside the lung area with intensities close to the lung wall intensities, which are mistakenly converted to the logical value of one, and are detected as non-lung parts .I read in a paper we can solve this problem with the method that I said but base on that you say it cant do this... do you have any suggestion for this? thanks
Image Analyst
2014년 9월 3일
You can but you have to define the algorithm better. Are you sure they're not just doing a morphological closing ()a local max)? If it's more like what you say then you need to answer by first comment. Maybe you just need to know if there is a 1 in any row of the left column and another 1 in any row of the right column. And, do we need to set the whole 3x3 window in the output image to 1 (very unusual), or just the center pixel where the window is centered (which is nearly every case I've ever seen)? Perhaps you can just do it with two simple calls to imfilter() or conv2() with a clever kernel, followed by thresholding and ANDing.
atefeh gh
2014년 9월 3일
I attach a file. Maybe it can show my purpose. I think use of 3*3 window is a difficult way Would you agree with me? one thing is not clear for me in this paper: I just know I should use a 3*3 window but I dont know what is the value of this window?
Image Analyst
2014년 9월 3일
You didn't attach anything, but I don't have much, or any, time for figuring out papers and explaining them to people, though people ask all the time. Sorry but I don't even have time for the papers I'd like to read, much less those that others are reading. Hope you understand. Maybe if it's a short paragraph explaining only that window-scanning part I might be able to figure out what they did, but no promises.
Joseph Cheng
2014년 9월 3일
편집: Joseph Cheng
2014년 9월 3일
It sounds like what is is being attempted is pass a low pass filter (if center value or all windowed pixel are replaced by its surroundings/edges) to get rid of small (based on the 3x3) "holes" or "peaks". If this is going to be a lung or rest of chest cavity binary image then wouldn't imfill() and/or imerode "fill"/"erode" these gaps in the image?
why not try a conv2() of ones(3,3)/9 (ie the average of the 3x3 window) and then putting a threshold based on what majority of ones vs zeroes would make it be replaced.
Image Analyst
2014년 9월 3일
No it's definitely not a low pass filter, that's a linear filter by the way. What he's asking for is a non-linear filter (median and dilation are some examples of non-linear filters). He wants to ignore the middle column and see if a pixel in the left column matches its partner on the right column (or maybe any pixel in the right column, that's what I'm asking him to tell us). So if you had two lines separated by a space (like edges of a bronchial tube), then it would fill in the space between the edges. It would not affect things outside the tube. Of course this is very dependent on window width and tube width. For example it would not work on edges separated by 3 or 4 columns of space. You'd have to use a bigger window for that and check more pixels. I'm wondering if the window size needs to be adjusted depending on the side of the tubes. Plus it would only work for vertical tubes, not horizontal ones.
I think there may be a way to construct this non-linear filter from two passes of a convolution with special kernels and thresholding but we need a better definition of how the left and right are compared to see how many kernels we'd need and what the threshold values need to be. But it wouldn't be a straight moving average (blurring).
Joseph Cheng
2014년 9월 3일
편집: Joseph Cheng
2014년 9월 4일
Ah i see, it has been a while and mixed the term with what i described with the averaging. Also i was thinking opposite edges included top and bottom of the 3x3 in the consideration of what the middle pixel will be. That is why i was thinking an averaging with a threshold on what constitutes how much of the window needed to be 1's or 0's
Image Analyst
2014년 9월 4일
You can filter with
1 0 0
1 0 0
1 0 0
with imfilter() to see if there are any "true" pixels on the left in your binary image. And you can filter with
0 0 1
0 0 1
0 0 1
in imfilter() to see if there are any in the right column. Then you can AND those output images together to see if there is at least one pixel in any row in the left column and in any row of the right column. Then you can OR that with your original binary image to fill in (set to 1) any pixel that has non-zero pixels in both the the left and right columns. You can't do it in a single convolution. If you need to match up row 1 with row 1, row2 with row2, and row3 with row3, then you need to just use a 1 row by 3 column kernel instead of a 3x3.
atefeh gh
2014년 9월 4일
thanks Image Analyst and Joseph I do what you said.the method that Joseph suggest is better for small holes.but it cant covered larger holes...so I think if we first use average and then use a larger filter for larger holes like what Image Analys suggested we can solve this problem ...do you agree with me?? I mean that how can we cover large holes?
Image Analyst
2014년 9월 4일
No I don't. I don't see why blurring the image would be preferable. Usually when people ask for image processing advice, they attach an image.
atefeh gh
2014년 9월 5일
Hi Image Analyst yes you said correct it just smoothed my image I put an image.the result I want below of that. I decide just to obtain the result of this. now I dont Emphasize on a special method ... thanks
Image Analyst
2014년 9월 5일
OK then if that's what you want, you can blur the image like this
blurredImage = conv2(double(binaryImage), ones(3)/9);
atefeh gh
2014년 9월 5일
so is there any Differences between what you say and this:
t1=1/9*[1 1 1;1 1 1;1 1 1];
t2=imfilter(binaryimage,t1);
like that Joseph said...am I right or not?
thanks Image Analyst
Image Analyst
2014년 9월 5일
I think that should be the same. Sometimes there are weird things about keeping classes the same so you'd need to check that. For example t2 mgiht be uint8 instead of double and thus not show fractional numbers but just round to 0 and 1. If that happens, just cast to double before sending in to imfilter.
atefeh gh
2014년 9월 3일
thanks David and Image Analyst I think I can do this by blockproc...I saw in help this: B = blockproc(A,[M N],FUN)
I want to explain the work that I want to do: I should apply 3*3 window based on this: if pexels located on two oposite sides of window have similar logical values(e.g,zero) all pixels covered by this window will be converted to that logical value(e.g,zero)
I want to know Is there any function can halep me to apply my work?? I hope I could explain my work to you.. Thanks in advance
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)