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일
0 개 추천
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일
0 개 추천
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
