Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I WANT TO BE ONLY EXTRACT TEXT IN GIVE IMAGE... I ATTACHED MY CODE .......... HELP TO SOLVE THE PROBLEM

조회 수: 1 (최근 30일)
Nivetha m
Nivetha m 2016년 4월 9일
마감: John D'Errico 2016년 5월 4일
clc
clear all
close all
fontSize = 20;
[I,map]=imread('C:\Users\shankar\Documents\MATLAB\measurement\specklenoise\speck.jpg');
subplot(2,2,1),imshow(I),title('original image', 'FontSize', fontSize),
I=double(I)/255;
v=var(I(:));
J=rgb2gray(I);
%J=imnoise(I,'gaussian',0,v/10);
%subplot(2,2,2),imshow(J),title('NOISE', 'FontSize', fontSize),
%%[m n]= size(J);
subplot(2,2,2),imshow(J),title('gray image', 'FontSize', fontSize),
H=fspecial('gaussian',13,9);
s=imfilter(J,H,'conv');
subplot(2,2,3),imshow(s),title('filter', 'FontSize', fontSize),
%%un sharpening
h=fspecial('unsharp');
shim=imfilter(s,h);
[m n]=size(shim);
%b = imsharpen(s,'Radius',2,'Amount',1);
%subplot(2,2,4),imshow(b),title('sharpe filter', 'FontSize', fontSize),
% global
format long g;
format compact;
fontSize = 20;
% Threshold level parameter alfa:
alfa=0.1;% less than 1/3
%a=imread('C:\Users\shankar\Documents\MATLAB\filtering\image.jpg');
%a=rgb2gray(a);
%[m n]=size(s);
max=max(max(shim));
min=min(min(shim));
t=((max+min)/2);
for i=1:m
for j=1:n
if shim(i,j)<t
b(i,j)=0;
else
b(i,j)=255;
end
end
end
%figure(1);
colormap(gray);
%subplot(2,2,1);imagesc(a);title('box','FontSize', fontSize);
%%subplot(2,2,4);imagesc(b);title('threshold one box','FontSize', fontSize);
%%un sharpening
hi=fspecial('unsharp');
shim1=imfilter(b,hi);
subplot(2,2,4);imagesc(shim1);title('threshold','FontSize', fontSize);
%%psnrr
squaredErrorImage = (double(shim) - double(b)) .^ 2;
mse = sum(sum(squaredErrorImage)) / (m * n);
RMSE = sqrt(mse);
PSNR = 10 * log10( 256^2 / mse);
mad = mean2(abs(double(shim)-double(b)));
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f.\n THE RMSE=%.2f .\n THE mad=%.2f',mse, PSNR,RMSE,mad);
msgbox(message);
[Updated from duplicate question]
The current code is:
%%Image segmentation and extraction
%%Read Image
imagen=imread('C:\Users\shankar\Documents\MATLAB\filtering\text.jpg'); %%imagen 365x550 200750 logical
%%Show image
figure(1)
imshow(imagen);
title('INPUT IMAGE WITH NOISE')
%%Convert to gray scale
if size(imagen,3)==3 % RGB image
imagen=rgb2gray(imagen);
end
%%Convert to binary image
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
%%Remove all object containing fewer than 30 pixels
imagen = bwareaopen(imagen,30);
pause(1)
%%Show image binary image
figure(2)
imshow(~imagen);
title('INPUT IMAGE WITHOUT NOISE')
%%Label connected components
[L Ne]=bwlabel(imagen); %%Ne 1x1 8 double
%%Measure properties of image regions
propied=regionprops(L,'BoundingBox'); %%%%Measure properties of image regions
hold on
%%Plot Bounding Box
for n=1:size(propied,1) %%n is single matrix 1X1
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2) %%g =green color
end
hold off
pause (1)
%%Objects extraction
figure
for n=1:Ne
[r,c] = find(L==n); %%n is single matrix 1X1 , L = 365x550 , r= 31X1 matrix
n1=imagen(min(r):max(r),min(c):max(c));
imshow(~n1); %% n1 12x7 84 logical
pause(0.5)
imsave();
end
%%CROP
%[area, bbox] = step(hblob, imagen);
  댓글 수: 1
Jan
Jan 2016년 4월 10일
Please format your code using the "{} Code" button. Then explain, what the problem is and the connection to the code.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by