Professional Documents
Culture Documents
size(img)
imshow('C:\Users\awill anurang misra\Desktop\vaibhav\vaibhav\a.jpg')
%Actually, a color image is a combined image of 3 grayscale images. So, we can display
the individual RGB components of the image using the following script:
subplot(131);
imagesc(img(:,:,1));
title('Red');
subplot(132);
imagesc(img(:,:,2));
title('Green');
subplot(133);
imagesc(img(:,:,3));
title('Blue');
colormap gray
%imadjust() adjust image intensity values. It maps the values in intensity image of an input
to new values in output image. This increases the contrast of the output image.
img = imread('C:\Users\awill anurang misra\Desktop\vaibhav\vaibhav\a.jpg');
gray = rgb2gray(img);
imshow(gray);
>> img = imread('C:\Users\awillanurang misra\Desktop\vaibhav\vaibhav\a.jpg');
gray = rgb2gray(img);
adj_img = imadjust(gray, [0.3,0.7],[]);
subplot(121);
imshow(gray);
title('input');
subplot(122);
imshow(adj_img);
title('adjusted');
im2bw() converts the grayscale image to a binary image. We'll use the adjusted image.
img = imread('ImageProcessing_1/Rachmaninoff.jpg');
gray = rgb2gray(img);
adj_img = imadjust(gray, [0.3,0.7],[]);
bw_img = im2bw(adj_img);
subplot(121);
imshow(adj_img);
title('input image');
subplot(122);
imshow(bw_img);
title('binary image');
This example shows how to use Wiener deconvolution to deblur images. Wiener deconvolution can be useful when the point-spread
function and noise level are either known or estimated.
Read Image
I = im2double(imread('cameraman.tif'));
imshow(I);
title('Original Image (courtesy of MIT)');
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
imshow(blurred);
title('Blurred Image');
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
noise_mean, noise_var);
imshow(blurred_noisy)
title('Simulate Blur and Noise')
The noise was amplified by the inverse filter to such a degree that only the barest hint of the man's shape is visible.
Restore the Blurred and Noisy Image: Second Attempt
In our second attempt we supply an estimate of the noise-power-to-signal-power ratio.
signal_var = var(I(:));
wnr3 = deconvwnr(blurred_noisy, PSF, noise_var / signal_var);
imshow(wnr3)
title('Restoration of Blurred, Noisy Image Using Estimated NSR');
uint8 representation
I = imread('cameraman.tif');
class(I)
ans =
uint8
If you pass a uint8 image to imfilter, it will quantize the output in order to return another uint8 image.
signal_var = var(im2double(I(:)));
wnr5 = deconvwnr(blurred_quantized, PSF, ...
uniform_quantization_var / signal_var);
imshow(wnr5)
title('Restoration of Blurred, Quantized Image Using Computed NSR');