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!