using median() instead of medfilt2()

10 ビュー (過去 30 日間)
Matthew Worker
Matthew Worker 2021 年 10 月 4 日
コメント済み: Rena Berman 2021 年 12 月 13 日
I am not sure how to do part b and well hence c as well. can you help with how to code this
my teacher requested using median()
i attached the image file
%% 2. Median Filter
sad1=imread('sadimg.bmp'); %a) Read ‘sadimg.bmp’ store image into ‘sad1’
median_filt=
  1 件のコメント
Rena Berman
Rena Berman 2021 年 12 月 13 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 10 月 4 日
Read the function information at https://www.mathworks.com/help/images/ref/blockproc.html more closely.
Hint: Use a 1 x 1 block and a border of [1 1]
Hint: Use TrimBorder false
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 4 日
Look at the documentation on blockproc. Notice that one of the parameters is an anonymous function that receives a struct and accesses a field of that struct and passes the data to a function to be processed.
@(SOMETHING) median(SOMETHING.APPROPRIATE_FIELD(:))
Image Analyst
Image Analyst 2021 年 10 月 4 日
blockproc normally moves in "jumps" of the block size when it scans the image. However it can move with an overlap, so that it would move over by just one pixel if you want. I attach demos for both ways.
However I think that if you want to move over just one pixel at a time, then the function you should probably use instead would be nlfilter(). You can have a custom filter where you did a median with the median() function. Demo attached for that also.

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 10 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by