Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

could anybody tell me how to turn image 1 with the noise to image 2?

1 visualización (últimos 30 días)
Omar Zoheir
Omar Zoheir el 15 de Ag. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
  2 comentarios
Image Analyst
Image Analyst el 15 de Ag. de 2020
Original question for when Omar deletes it like he did the other one:
could anybody tell me how to turn image 1 with the noise to image 2?
Image 2:

Respuestas (1)

Image Analyst
Image Analyst el 15 de Ag. de 2020
The first image looks way over exposed so it may not be possible. But you'd want to invert it:
grayImage = 255 - grayImage;
then use my attached salt and pepper noise correction program.
  2 comentarios
Omar Zoheir
Omar Zoheir el 15 de Ag. de 2020
i tried using your salt and pepper correction, the texture doesn't get fixed, the noise also doesn't all go away, could you please suggest something else?
Image Analyst
Image Analyst el 15 de Ag. de 2020
I should have said "Adapt as needed". If you adapt it to look for not just where the noise is 0 or 255 but where the noise is more than some difference from the original (inverted) image and the median filtered version of the image, it works pretty good. Here is the adapted code:
% Demo to remove "salt and pepper" noise from a gray scale image,
% with a modified median filter that acts only on the noise pixels
% and not upon "good" non-noise pixels.
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 15;
% Read in a standard MATLAB demo image.
originalImage = imread('1.jpg');
% Get the dimensions of the image. numberOfColorBands should be = 1.
[rows, columns, numberOfColorChannels] = size(originalImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
originalImage = rgb2gray(originalImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the original image.
subplot(2, 3, 1);
imshow(originalImage);
title('Original Noisy Gray Scale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
% Invert the image
noisyImage = 255 - originalImage;
imshow(noisyImage);
title('Inverted Noisy Gray Scale Image', 'FontSize', fontSize);
% Median Filter the image:
medianFilteredImage = medfilt2(noisyImage, [3 3]);
subplot(2, 3, 2);
imshow(medianFilteredImage);
title('Image Filtered with Median Window', 'FontSize', fontSize);
% Find the noise.
noiseOnlyImage = imabsdiff(noisyImage, medianFilteredImage);
% Display the image.
subplot(2, 3, 3);
imshow(noiseOnlyImage);
title('Noise-only Image', 'FontSize', fontSize);
% Display the histogram of the difference image.
subplot(2, 3, 4);
histogram(noiseOnlyImage, 512);
grid on;
title('Histogram of noise', 'FontSize', fontSize);
% 15 looks like a decent threshold.
% Make a mask for where the noise is more than 25.
noiseMask = noiseOnlyImage > 15;
% Display the image.
subplot(2, 3, 5);
imshow(noiseMask);
title('Mask of Noise Locations', 'FontSize', fontSize);
% Get rid of the noise by replacing with median.
noiseFreeImage = noisyImage; % Initialize to inverted original image.
noiseFreeImage(noiseMask) = medianFilteredImage(noiseMask); % Replace.
% Display the image.
subplot(2, 3, 6);
imshow(noiseFreeImage);
title('Noise-reduced Image', 'FontSize', fontSize);

Productos


Versión

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by