Gilad
Gilad

Reputation: 6595

image enhancement - cleaning given image from writing

enter image description here

i need to clean this picture delete the writing "clean me" and make it bright.

as a part of my homework in image processing course i may use matlab functions ginput, to find specific points in the image (of course in the script you should hard code the coordinates you need).

You may use conv2, fft2, ifft2, fftshift etc.

You may also use median, mean, max, min, sort, etc.

my basic idea was to use the white and black values from the middle of the picture and insert them into the other parts of the black and white strips. however gives a very synthetic look to the picture.

can you please give me a direction what to do ? a median filter will not give good results.

Upvotes: 4

Views: 1440

Answers (4)

Guy P
Guy P

Reputation: 1423

I used gausswin() function to make a gaus. mask:

Pic_usa_g =  abs(1 - gausswin(  size(Pic_usa,2)  ));
Pic_usa_g = Pic_usa_g + 0.6;
Pic_usa_g = Pic_usa_g .* 2;
Pic_usa_g = Pic_usa_g';
C = repmat(Pic_usa_g, size(Pic_usa,1),1);

G_Mask

and after multiply the image with the mask you get the fixed image.

Res

Upvotes: 0

mmgp
mmgp

Reputation: 19241

The general technique to do such thing is called Inpainting. But in order to do it, you need a mask of the regions that you want to in paint. So, let us suppose that we managed to get a good mask and inpainted the original image considering a morphological dilation of this mask:

enter image description here enter image description here

To get that mask, we don't need anything much fancy. Start with a binarization of the difference between the original image and the result of a median filtering of it:

enter image description here

You can remove isolated pixels; join the pixels representing the stars of your flag by a combination of dilation in horizontal followed by another dilation with a small square; remove this just created largest component; and then perform a geodesic dilation with the result so far against the initial mask. This gives the good mask above.

Now to inpaint there are many algorithms, but one of the simplest ones I've found is described at Fast Digital Image Inpainting, which should be easy enough to implement. I didn't use it, but you could and verify which results you can obtain.

EDIT: I missed that you also wanted to brighten the image.

An easy way to brighten an image, without making the brighter areas even brighter, is by applying a gamma factor < 1. Being more specific to your image, you could first apply a relatively large lowpass filter, negate it, multiply the original image by it, and then apply the gamma factor. In this second case, the final image will likely be darker than the first one, so you multiply it by a simple scalar value. Here are the results for these two cases (left one is simply a gamma 0.6):

enter image description here enter image description here

If you really want to brighten the image, then you can apply a bilateral filter and binarize it:

enter image description here

Upvotes: 2

Vidar
Vidar

Reputation: 4221

The simplest way to remove the text is, like KlausCPH said, to use a long 1-d median filter in the region with the stripes. In order to not corrupt the stars, you would need to keep a backup of this part and replace it after the median filter has run. To do this, you could use ginput to mark the lower right side of the star part:

% Mark lower right corner of star-region
figure();imagesc(Im);colormap(gray)
[xCorner,yCorner] = ginput(1);
close
xCorner = round(xCorner); yCorner = round(yCorner);

% Save star region
starBackup = Im(1:yCorner,1:xCorner);

% Clean up stripes
Im = medfilt2(Im,[1,50]);

% Replace star region
Im(1:yCorner,1:xCorner) = starBackup; 

This produces enter image description here

To fix the exposure problem (the middle part being brighter than the corners), you could fit a 2-D Gaussian model to your image and do a normalization. If you want to do this, I suggest looking into fit, although this can be a bit technical if you have not been working with model fitting before.

My found 2-D gaussian looks something like this: enter image description here

Putting these two things together, gives: enter image description here

Upvotes: 1

KlausCPH
KlausCPH

Reputation: 1835

I see two options for removing "clean me". Both rely on the horizontal similarity.

1) Use a long 1D low-pass filter in the horizontal direction only.

2) Use a 1D median filter maybe 10 pixels long

For both solutions you of course have to exlude the stars-part.

When it comes to brightness you could try a histogram equalization. However that won't fix the unevenness of the brightness. Maybe a high-pass before equalization can fix that.

Regards

Upvotes: 1

Related Questions