Hello. I need you to help me with an example of a median filter with a 3x3 pixel to an image that I gave the noise of salt and pepper.
2 ビュー (過去 30 日間)
古いコメントを表示
close all
clear all
clc
A=imread('GT-1200_Topcon_total-robotic-station-W-min.jpg');
figure;
imshow(A);
title('LEICA');
% Dhenia zhurem imazhit
B=imnoise(A,'salt & pepper',0.1);
figure;
imshow(B);
% Paraqitja e histogrames te imazhit orgjinal dhe te imazhit me zhurem
subplot(2,2,1), imshow(A), title('Imazhi orgjinal');
subplot(2,2,2), imshow (B),title('Imazhi me zhurem');
subplot(2,2,3); imhist(A);
title('Histograma e imazhit origjinale');
subplot(2,2,4); imhist(B);
title('Histograma e imazhit me zhurem');
0 件のコメント
回答 (4 件)
DGM
2023 年 1 月 16 日
Image Analyst has a set of fixed-window noise removal filter demos posted on the forum. These are grayscale, but the concept extends to RGB with as little as a loop.
I posted an example of both fixed and adaptive median noise removal filters on RGB images here:
... and with a bit more detail here
There are also other examples on the File Exchange.
2 件のコメント
DGM
2023 年 1 月 17 日
編集済み: DGM
2023 年 1 月 17 日
I can't be sure with the given information, but you should be aware that medfilt2() only supports single-channel (i.e. mxnx1) inputs. If your image is JPG, it's likely RGB instead.
If your image is RGB, but has no meaningful color content, you might choose to reduce it using im2gray() or rgb2gray(). The result would then be compatible with medfilt2().
Alternatively, if you want to process a color image, you can either use medfilt2() in a loop, or you can use medfilt3() with a 2D window parameter (e.g. [5 5 1]). The second link I posted actually has examples of both.
% fixed noise removal filter for I/RGB
inpict = imread('peppers.png');
% inpict = im2gray(inpict); % convert RGB to I if desired
noisypict = imnoise(inpict,'salt & pepper',0.1);
imshow(noisypict)
medpict = medfilt3(noisypict,[5 5 1]);
mask = (noisypict == 0) | (noisypict == 255);
outpict = noisypict;
outpict(mask) = medpict(mask);
imshow(outpict)
Image Analyst
2023 年 1 月 16 日
See attached salt and pepper denoising demos, one for color and one for grayscale.
Adapt as needed.
5 件のコメント
Image Analyst
2023 年 1 月 17 日
OK, still waiting for the image to be attached and the results of the whos and size commands to be given.
I'll check back later for them.
Xheni
2023 年 1 月 27 日
編集済み: Xheni
2023 年 1 月 27 日
3 件のコメント
Image Analyst
2023 年 1 月 28 日
Walter answered that. An "edge" is not well defined in color. If you do somehow define it, then you're going to be talking about a monochrome image, for example if there is no change in brightness but there is a change in hue, then you'd have no change in the V channel if you converted it to HSV color space, but you would have a change in the H channel. So you'd just get the edges in that one monochrome H channel. Or, like he said, you can do it in all three color channels in whatever color space you want and then somehow combine them.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!