How to deblur an image where the text is blurred by imgaussfilt() function?

9 ビュー (過去 30 日間)
Martin Adrian Enghoy
Martin Adrian Enghoy 2022 年 1 月 31 日
コメント済み: Image Analyst 2022 年 1 月 31 日
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
Blurred Text
deconvlucy()
and deconvreg()
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!

回答 (2 件)

Image Analyst
Image Analyst 2022 年 1 月 31 日
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)

ali hassan
ali hassan 2022 年 1 月 31 日
what is the benifit of bluring and what are its application?
  1 件のコメント
Image Analyst
Image Analyst 2022 年 1 月 31 日
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by