sir i am working on impulse (salt and pepper) noise from fingerprint images.i am using database 1 (DB1_B) from FVC 2000 International Competition on Fingerprint Verification as test images.Please check the attached code.the result this code gives is

2 views (last 30 days)
for j=1:20
for i= 1:80 % Setting the variable for image under process
% To select the image from data base DB1_B
select_img=['C:\Users\Sana\Desktop\progprc\DB1_B\101_', num2str(i) '.tif'];
%inputn=input('select image(ddf:');
%inn=imread(inputn);
img=imread(select_img);
image_1d=img(:);
image_double=double(image_1d);
% To set the frame length
Num_pixles=length(image_double); % Total number of pixels
mean_power=0; % Local mean power
frame_length=Num_pixles; % withoutframmin
T_num_frames=floor(Num_pixles/frame_length);
%frame_length=480; % Number of pixel per frame
%T_num_frames=floor(Num_pixles/frame_length); % Total number of frames
% Setting an arrays for processed image
new_signal = zeros(Num_pixles,1);
mean_array = zeros(T_num_frames,1);
% Setting the SNR value
snr_vlaue=j;
v1=mean(image_double)/(10^(snr_vlaue/10)); % snr=10log(mean of image/Var of image)
v11=v1^2;
u=v11/(255*255);
% Adding noise into the selected image
add_image_noise=imnoise(image_1d,'salt & pepper',u);
image_noise_d=double(add_image_noise);
% To find the frame having maximum mean power & store its Mean Power value into max_mean_array_ch
mean_array_ch=zeros(T_num_frames,1);
for ch=1 : T_num_frames
frame = image_noise_d( (ch-1)*frame_length+1: frame_length*ch); % Taking frame from whole iamge
mean_power_ch=0; % Zero the mean power for next calculation
for n=1 : T_num_frames
mean_power_ch = mean_power_ch + frame( n,1) * frame(n,1);
end
mean_array_ch(ch,1)= mean_power_ch; % Storing the value of Mean Power
end
max_mean_array_ch=max(mean_array_ch); % The maximum Mean Power
% To set the threshold and boosting value
th_value=(max_mean_array_ch)*0.1; % The Threshold value
mean_image_noise=mean(add_image_noise); % Mean of all pixels of noisy image
boost=255/(mean_image_noise); % The boosting value
%calculating the mean power sum of the frame and removing that frame value which is less then threshold value
for k=1 : T_num_frames
frame = image_noise_d( (k-1)*frame_length+1: frame_length*k); % Taking frame from whole image
mean_power=0; % Zero the mean power for next calculation
for n=1 : T_num_frames
mean_power = mean_power + frame( n,1) * frame(n,1); % calculating the mean power sum of the current frame
end
mean_array(k,1)= mean_power; % storing the current mean power sum in mean_array
if( mean_power >=th_value)
% If mean_power is greater than threshold value then multiply the value of that frame by boosting value
new_signal((k-1)*frame_length+1: frame_length*k) = (boost).*frame;
else
new_signal((k-1)*frame_length+1: frame_length*k) = (0).*frame;
end
end
% Reconstruction of images
image_input=reshape(image_1d,480,640);
noisy_image= reshape(add_image_noise,480,640);
proc_image=uint8(new_signal);
proc_image1=reshape(proc_image,480,640);
%to store the noisy image
file_name_noise=['C:\Users\sana\Desktop\DB\ni\' num2str(j) num2str(i) '.tif'];
imwrite(noisy_image,file_name_noise);
% To stor the processed image
file_name_proc=['C:\Users\sana\Desktop\DB\pi\' num2str(j) num2str(i) '.tif'];
imwrite(proc_image1,file_name_proc);
%similarity checking
ssimval=ssim(proc_image1,img);
scaledi=mat2gray(((ssimval)*(1-eps))+eps(realmin));
y=fprintf('ssim alue is %.4f\n',scaledi);
ssimvali=ssim(noisy_image,img);
scaledii=mat2gray(((ssimvali)*(1-eps))+eps(realmin));
figure(2);
plot(j,scaledi,'.',j,scaledii,'pg');
hold on
z=fprintf('ssim of nosy imae is %0.4f\n',scaledii);
end
end

Answers (1)

Image Analyst
Image Analyst on 25 Jun 2023
You forgot to attach your image. See attached salt and pepper noise removal demos.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!