現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)