How to deblur an image where the text is blurred by imgaussfilt() function?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Currently, we have built our ID text blurring code using ocr() to detect all the text found on the image file then create a gaussian blur mask for each line of text using poly2mask from the values stored in bboxes.
Here's the code:
%Read Image
ID = imread('passport1.jpg');
imageSize = size(ID);
h = fspecial('disk', 3);
%Detect all text on ID
ocrResults = ocr(ID);
bboxes = ocrResults.WordBoundingBoxes(:,:);
[x,y] = size(bboxes);
for i = 1:x
xi = horzcat(bboxes(i,1), bboxes(i,1), ...
bboxes(i,1) + bboxes(i,3), bboxes(i,1) + bboxes(i,3));
yi = horzcat(bboxes(i,2), bboxes(i,2) + bboxes(i,4), ...
bboxes(i,2) + bboxes( i,4 ), bboxes(i,2));
%Convert Region of Interest to region mask
binaryImage = poly2mask(xi, yi, imageSize(1), imageSize(2));
%Use gaussian filter w/ 10 standard dev for larger filter
blurredImage = imgaussfilt(ID,20);
%Mask with 'same' option to retain size of
%output array from input array
blurredMask = imfilter(im2double(binaryImage),h,'same');
%Rescale image
ID = im2uint8(im2double(blurredImage).*blurredMask + im2double(ID).*(1-blurredMask));
end
imshow(ID);
We tried functions such as deconvlucy():
luc1 = deconvlucy(ID,h,15);
imshow(luc1);
and deconvreg():
noiseMean = 0;
noiseVar = 0.01;
blurred_noisy = imnoise(ID,'gaussian',noiseMean,noiseVar);
noisePower = noiseVar*numel(ID);
Edged = edgetaper(blurred_noisy,h);
reg3 = deconvreg(Edged,h,noisePower/1.2);
%subplot(133); imshow(reg3);
figure(2); imshow(reg3);
---which are added after the for loop so we can immediately see how the image was deblurred.
Here are the images:
Start
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/879785/image.jpeg)
Blurred Text
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/879790/image.png)
deconvlucy()
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/879795/image.png)
and deconvreg()
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/879800/image.png)
After using the deblurring functions, it looks like it did little to no work on the filters
I would like to ask if there's a way to reverse the imgaussfilt() function that was used for the text blurring
Attached is the starting image file as well.
Thank you in advance!
Respuestas (2)
Image Analyst
el 31 de En. de 2022
There's no way. The information has been totally lost and obliterated. No amount of deblurring will restore that in an image that has been converted to uint8 and saved to an image file. Perhaps if you had the original blurred image in floating point, but even there, I doubt it. This is real world, not Hollywood:
(Most hilarious misuse of image processing in movies)
0 comentarios
ali hassan
el 31 de En. de 2022
what is the benifit of bluring and what are its application?
1 comentario
Image Analyst
el 31 de En. de 2022
Well, it can obscure details in a picture, as you can see from your example. You can also use it to estimate a background in an image that is mostly background but with small foreground parts.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!