if, for loop, median

3 ビュー (過去 30 日間)
Manpreet Kapoor
Manpreet Kapoor 2011 年 4 月 11 日
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
Walter Roberson 2011 年 4 月 11 日
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
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
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 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by