How to Deblur Color JPEG Images Using the Blind Deconvolution?

9 views (last 30 days)
Hello,
I am going through the example of deblurring an image using blind deconvolution in the Image Processing toolbox documentation.
Throughout that example, a grayscale TIFF image is used. I would like to use a truecolor JPEG image of mine instead. Is this possible?
I was able to go through the example and create the first 6 figures, up through the 2x2 plot of the 4 different PSFs. Then I ran into problems.
The first problem I ran into was on this line:
WEIGHT = edge(I,'sobel',.3);
The error was: Error using edge Expected input number 1, I, to be two-dimensional.
Error in edge>parse_inputs (line 547)
validateattributes(I,{'numeric','logical'},{'nonsparse','2d'},mfilename,'I',1);
Error in edge (line 190)
[a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
Error in deblur_blind_deconvolution (line 55)
WEIGHT = edge(I,'sobel',.3);
I was able to get past that by changing the line that calls edge() to this:
WEIGHT = edge(rgb2gray(I),'sobel',.3);
But that gives me a different problem later on:
Error using deconvblind>parse_inputs (line 374)
If not a scalar, WEIGHT has to have size of the input image.
Error in deconvblind (line 122)
[J,P,NUMIT,DAMPAR,READOUT,WEIGHT,sizeI,classI,sizePSF,FunFcn,FunArg] = ...
Error in deblur_blind_deconvolution (line 63)
[J P] = deconvblind(Blurred,INITPSF,30,[],WEIGHT);
In this scenario, Blurred is a m x n x 3 matrix of uint8 values. WEIGHT is m x n matrix of double values.
I have found one way to get around this, but it is not satisfactory. After reading in the original image, I can convert it to grayscale right away, then just use that grayscale image throughout the deblur process (in the call to edge(), revert back to simply using I):
I = imread('mycolorjpgimage.jpg');
figure;imshow(I);title('Original Image');
I = rgb2gray(I);
But now I am stuck with a grayscale image at the end. Is there some way to convert to color and recover all of the original color data after the deblurring?
Another possibility I am thinking of is somehow converting WEIGHT from m x n to m x n x 3. But I'm stuck on how to do that.
Any help? Is deblurring a color jpeg with the WEIGHT array even possible?
(Apologies if this has been answered somewhere else already. I have googled around for hours now and have yet to find anything that addresses this specifically.)
  4 Comments
Thishan
Thishan on 1 Apr 2013
i am suffering from the same problem did you find an answer?

Sign in to comment.

Answers (1)

Le Chen
Le Chen on 1 Apr 2020
Hi,I have the same problem ,do you find an answer?

Community Treasure Hunt

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

Start Hunting!