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 vues (au cours des 30 derniers jours)
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');

Réponses (4)

DGM
DGM le 16 Jan 2023
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 commentaires
Xheni
Xheni le 17 Jan 2023
Thank you very much for your comment, I really appreciate it. The script I showed you above requires that in the median filter you set pixel sizes 4x4, 5x5 and 10x10 when I do it E = medfilt2(B,[4 4]); figure; imshow(E); title ( '4x4 Median Filter' ); imhist(E); title ( '4x4 Median Filter Histogram' ); Where B is the image with noise. When I click run on the window command, I get an error Error in medfilt2 (line 49) [a, mn, padopt] = analyze_inputs(args{:}); Error in Assignment (line 50) E = medfilt2(B,[4 4]); I don't understand why it happens to me like this, I spend many days watching different videos, reading articles, but I still haven't found a solution.
DGM
DGM le 17 Jan 2023
Modifié(e) : DGM le 17 Jan 2023
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)

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 16 Jan 2023
See attached salt and pepper denoising demos, one for color and one for grayscale.
Adapt as needed.
  5 commentaires
Image Analyst
Image Analyst le 17 Jan 2023
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.

Connectez-vous pour commenter.


Xheni
Xheni le 27 Jan 2023
Modifié(e) : Xheni le 27 Jan 2023
Hello.
I have read some notes but I don't understand why operators like cany, log and prewitt only work with black and white image.
When I run the script where I have the cany operator, I get a graph but I don't understand what it says, can you help me please
  3 commentaires
Xheni
Xheni le 28 Jan 2023
My question is why cany operators only recognize black and white images and not color ones
Image Analyst
Image Analyst le 28 Jan 2023
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.

Connectez-vous pour commenter.


Xheni
Xheni le 28 Jan 2023

Community Treasure Hunt

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

Start Hunting!

Translated by