Sliding window for image
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Hi can anyone show me how to use a 32x32 sliding window on an image using and extract the mean from each window?
Thanks
採用された回答
Image Analyst
2014 年 4 月 18 日
You can use conv2() or imfilter() to slide a 32 by 32 window across the image by one pixel at a time and get the mean. Nearly always an odd size (31 or 33) is used because then there are the same number of pixels to the left and right - the window is centered over the pixel. With an even number, the output and input images are shifted by a half pixel. Here's the code:
kernel = ones(32)/32^2; % Create averaging window.
output = conv2(grayImage, kernel, 'same'); % Get means.
If you want to move over in jumps of 32 pixels instead of 1 pixel, see my demos for blockproc (attached).
13 件のコメント
Ciara
2014 年 4 月 18 日
Thank you. But whenever I do imshow(output) I get the whole image, not a window of it. Is there more code I need to add?
Image Analyst
2014 年 4 月 18 日
Of course you get the whole image. The window scans the whole image. What do you want? The window visits hundreds of thousands of locations as it moves over the original image. What subimage out of hundreds of thousands do you want to display? All of them? That would take hours or days to finish.
Ah ok!
so If I use
kernel = ones(32)/32^2; % Create averaging window.
output = conv2(grayImage, kernel, 'same'); % Get means
mean=mean(mean(output);
display (mean);
should this return the mean value of every window?
Image Analyst
2014 年 4 月 18 日
Uh, yeah, sort of. But why do that when
meanGL = mean2(grayImage);
will get you the same thing without sliding a window along? The mean of the means is the same as the mean of the whole image.
Also, don't call mean and then set the answer to a variable called mean. You'll never be able to call mean again in that program because you just blew away the built-in function by redefining it to be a variable of the same name in your program.
Ciara
2014 年 4 月 18 日
because I need to find the mean intensity of the pixels in each window.
here is my algorithm:
split image into 32x32 windows
if average intensity within 32x32 window>210
split the 32x32 window into an 8x8 window
end
Image Analyst
2014 年 4 月 18 日
output is a collection of all your means. No need to take the mean after that.
I don't know what you're doing with this further breakdown into 4 8 by 8 quadrants within the 32 by 32 window. What's the purpose of that? That would require 4 means for every pixel location instead of just one. Why do that???
Ciara
2014 年 4 月 22 日
because I am using the following algorithm from this paper to find an ROI in breast profile image. http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3097782/figure/F7/
Can you help me with this? I am really struggling
Image Analyst
2014 年 4 月 22 日
It first does 32 wide blocks. Then 8 wide blocks. It does not do the 8 on the output of the 32. It does it on the original image. But I'm not sure because I don't know what "Combine image" means. You'll have to take more time to understand what the paper is doing. http://matlab.wikia.com/wiki/FAQ#Can_you_program_up_the_algorithm_in_this_article_for_me_and_explain_it_to_me.3F
Ciara
2014 年 4 月 22 日
How do I contact a consultant?
Image Analyst
2014 年 4 月 22 日
The Mathworks has consultants that they can connect you with. You can call them.
Kit Hui
2015 年 12 月 11 日
Hi, Image Analyst. For this case. Could I ask you if I'm not just calculating the mean of each 32x32 window but also the standard deviation?. How can I do that?
Image Analyst
2015 年 12 月 11 日
Kit, you can use stdfilt():
sdImage = stdfilt(grayImage, ones(32));
Marium Azhar
2017 年 3 月 12 日
if i want to apply some other operation instead of mean std deviation etc. i mean if i just want to run a 5x5 sliding window over the whole image? then?
その他の回答 (1 件)
Joseph Cheng
2014 年 4 月 17 日
You can use blockproc().
M=magic(10);
fun =@(MEANS) mean(MEANS.data(:));
blockproc(M,[2 2],fun)
1 件のコメント
Ciara
2014 年 4 月 17 日
Thanks. What is
M=magic(10);
カテゴリ
ヘルプ センター および File Exchange で Neighborhood and Block Processing についてさらに検索
参考
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)
