My project is on extracting text from image. i try below code but i did not get clear output , i get only noisy text image , please help me to solve my proplem
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clc clear all close all %---------------- format long g; format compact; fontSize = 20; %% ----------------------- fact=0.1; I1=imread('C:\Users\shankar\Documents\MATLAB\filtering\2.jpg'); figure(1),imshow(I1),title('Original Image', 'FontSize', fontSize); set(gcf, 'Position', get(0,'Screensize')); % Maximize figure. I2 = rgb2gray(I1); figure(2),imshow(I2),title('Original Gray Scale Image', 'FontSize', fontSize); %% noise I3 = imnoise(I2,'salt & pepper',0.02); %[rows columns] = size(I3); figure(3), imshow(I3),title('salt', 'FontSize', fontSize); %% MEDIAN I = filter2(fspecial('average',3),I3)/255; I = medfilt2(I3); figure(4),imshow(I),title('Kmedian', 'FontSize', fontSize);
%% thre--------------------------------- i=im2bw(I); imax=max(max(i)); imin=min(min(i)); %%L=fact*(imax-imin)+imin; L=((imax+imin)/2); thre=max(i,L.*ones(size(i))); colormap(gray); imagesc(i) imagesc(thre) figure(5),imshow(thre),title('THRE', 'FontSize', fontSize); %% noise I5 = imnoise(thre,'salt & pepper',0.02); [rows columns] = size(I5); figure(6), imshow(I5),title('salt', 'FontSize', fontSize); %% canny %I6 = filter2(fspecial('average',3),I5)/255; %I = medfilt2(I5); I6=edge(I5,'canny'); figure(7),imshow(I6),title('Kmedian', 'FontSize', fontSize); %% ------ PSNR CALCULATION ---------------------------------------------------------- %squaredErrorImage = (double(I) - double(thre)) .^ 2; % Display the squared error image. %subplot(2, 2, 3); %imshow(squaredErrorImage, []); %title('Squared Error Image', 'FontSize', fontSize); % Sum the Squared Image and divide by the number of elements % to get the Mean Squared Error. %mse = sum(sum(squaredErrorImage)) / (rows * columns); % Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula. %PSNR = 10 * log10( 256^2 / mse); % Alert user of the answer. %message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR); %msgbox(message); %% PSNR origImg = double(I5); distImg = double(I6); [M N] = size(origImg); error = origImg - distImg; MSE = sum(sum(error .* error)) / (M * N); if(MSE > 0) PSNR = 10*log(255*255/MSE) / log(10); else PSNR = 99; end message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', MSE, PSNR); msgbox(message);
INPUT IMAGE:
OUTPUT IMAGE:
0 commentaires
Réponses (1)
Image Analyst
le 23 Avr 2016
Try my attached demo. I think it might work well for you if you tweak some of the parameters.
5 commentaires
Image Analyst
le 24 Avr 2016
That's a 7 year old version! MATLAB has progressed quite a bit since then. Time to upgrade.
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!