if, for loop, median
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
hi, I am new to matlab programming. I wish to write a program involving image processing, which serves the following purpose: consider a 3x3 window in a normalised 512x512 image. Compare each value of the pixel with 0.3. If the value of image pixel is less than 0.3, sort the vector, and find the median of all the pixels with value less than 0.3. And if value is more than 0.3, neglect that pixel value, and find median of all remaining pixels which have values less than 0.3. All of this should result in a new image. Thanks and Regards Manpreet Kapoor
채택된 답변
Walter Roberson
2011년 4월 11일
1 개 추천
Is this 3 x 3 window to be slid overlapping over the whole image, or is the image to be broken up in to 3 x 3 blocks? If it is to be broken up in to 3 x 3 blocks, there is a problem because 512 is not divisible by 3.
You can use sorting to find the median if you want, but there is a median() function. For example, if P are the pixels in the window, then
median(P(P<0.3))
댓글 수: 10
Manpreet Kapoor
2011년 4월 11일
walter,
please dont concentrate on the size of the image, wat I want is the program to implement the logic given. I just want to see the way the functions are designed....
Walter Roberson
2011년 4월 11일
The logic for overlapping blocks is different than for non-overlapping blocks.
If you are using non-overlapping blocks, see
http://www.mathworks.com/matlabcentral/answers/5163-image-block-block-dividing
Manpreet Kapoor
2011년 4월 11일
walter,
it is overlapping window, coz the median needs to be found for every pixel window, thus forming a new image. I know the function to be used is nlfilter, wat i want to know is the sequence of commands to perform the above said function. I basically need to learn the usage of functions in a program.
Walter Roberson
2011년 4월 11일
I'm not familiar with nlfilter, but it does appear suitable
B = nlfilter(A,[3,3],@(x) median(x(x<0.3)));
The rest of the problem statement is noise, two equivalent conditions.
Manpreet Kapoor
2011년 4월 11일
hi
this command does not work, even wen I defined both A and B.... Wat to do?
Walter Roberson
2011년 4월 11일
Please be more specific about what you mean by "does not work". Do you have the image processing toolbox?
You might want to try the example given in the documentation,
http://www.mathworks.com/help/toolbox/images/ref/nlfilter.html
Manpreet Kapoor
2011년 4월 11일
walter,
I have already gone through the above document earlier, wat I am facing trouble is in the the designing of 'fun' which performs the median of the pixel values less than 0.3.
I already mentioned I am new to matlab and programming watsoever, so cant understand the implementation of 'fun'. Please help.....
Walter Roberson
2011년 4월 11일
Okay, so let's go back to you being more specific about the command not working. What exactly do you mean by that? If the cameraman example from the documentation worked for you, then my very small variation on it should work. The cameraman example had median(x(:)) and I have median(x(x<0.3)) . For an array, x(x<0.3) will return a vector suitable for input to median, and that vector will consist only of the pixels with value less than 0.3 .
Manpreet Kapoor
2011년 4월 11일
Sorry for the misunderstanding earlier, the logic u gave is absolutely correct, but the problem I have now is that nlfilter takes almost an hour to code one image, hence another command I found faster is colfilt.
can u offer any help in this....???
any help will be highly appreciated.
Thanks and Regards
Walter Roberson
2011년 4월 11일
Sorry, I am not familiar with colfilt .
I would think it likely that blkproc() or blockproc() would be much faster than nlfilter.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Neighborhood and Block Processing에 대해 자세히 알아보기
태그
참고 항목
2011년 4월 11일
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)
