how can i set the pixel intensity values (I) that fall in the range, 200> I >30 to I = 200.

 Respuesta aceptada

Try adapthisteq(). Try it yourself first. It will get rid of the dark background and normalize all the writing. try different parameters until you get it correct. Come back with your code if you need help.

10 comentarios

ThankYou very much Sir! I guess i am getting close to the results i was expecting, i'm gonna experiment a little bit with the parameters and that should get my job done. However i have another question - How can i automatically find images like these from a bunch of images which have majority of good ones but very few images with blacked out areas on it. How can i automate this process to separate the faulty images so that i can enhance them later ?
You can take the histogram and look for histograms that have a certain number of dark pixels. To distinguish against pages that just have a lot of text on them, you can threshold and look for large regions. Like
binaryImage = grayImage < threshold;
% Find blobs that are larger than 1000 pixels.
binaryImage = bwareaopen(binaryImage, 1000);
if sum(binaryImage(:)) > 0
% Then there are large blobs
% Need to run adapthisteq
else
% No large blobs.
% No need to run adapthisteq.
end
Thank You very much, I got it!!
If you want just big roundish or rectangular blobs but not line-like blobs, construct the circularities:
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerims = [measurements.Perimeter];
circularities = allPerims.^2 ./ (4*pi*allAreas);
% Find non-line-like blobs
fatBlobIndexes = find(circularities > 5); % or some value that works.
% Extract fat blobs
fatBlobsOnly = ismember(labeledImage, fatBlobIndexes)>0;
imshow(fatBlobsOnly);
Thanks for the response but i still have the same problem, the code still picks up the line for " find(circularities > 5) " and i kept varying the values and it did'nt pick up when " find(circularities > 300) " but this now again does'nt pick up those small polygons. I donno if i am doing anything wrong but i can't get it.
I think I should have put circularities < 5. If it's greater than 5 it will select the lines, not the round blobs. If it's less than 5 you'll get roundish blobs.
dp sb
dp sb el 23 de Jul. de 2015
Editada: dp sb el 23 de Jul. de 2015
It works Sir!
But here's the problem. When i go circularities < 5 (also upto < 50), i am not picking up any lines because they have circularities ranging from 50-200 (These ranges are just for the few sample images i looked into). In general i could say that there are few images with 2 or 3 lines detected and they have circularities like 60, 90, 160 etc. And the real blobs that i am looking for are polygon shapes (basically blocks and very very few circles). So the circularities for the blobs that i am looking for have ranges anything > 3 (Again i came to conclusion on these ranges just by seeing very few sample images)
So the big problem for me is that i am working on a very very large set of images and i can not come to a desired parameter to set up this condition. Is there another way that i could just eliminate all the lines and look into other blobs.
I think there's definitely a way out but i can't get there as i don't have much experience. I would greatly appreciate any help on this.
Thank You very much!
What happened to your original question and the image you posted? I can't find them. So remind me what kind of blobs you want to keep and what kind of blobs you want to reject. Can you at least upload a binary image and say what you want the output image to include?
dp sb
dp sb el 24 de Jul. de 2015
Editada: dp sb el 24 de Jul. de 2015
Here's two images.
The above binary image picked up line which i didnt want to but i could eliminate them by looking for circularities <5 until <50. this particular image has two lines with circularities 60 and 90.
But the problem comes here, have a look at this image,
This image has a small blob which i want my code to pick up coz it's blacked out and has information to read in it. this blob has circularity of 15. so when i try to go <5 i could eliminate lines but also am eliminating blobs like these which i dont want to. i could also go < 50 and which will not elimate a blob like this but the problem is this is a small blob and there are images with large blobs and circularities upto 200. i can't come with an optimum parameter which can give me desired results. Is there an other way with which i could eliminate lines and only look at blobs with shapes like blocks or small circles.
Plz help, Thank You.
You might try bwconvhull() on the binary image before calculating the area and perimeter. This will round out the blobs and make that bottom one have not so high a circularity.

Iniciar sesión para comentar.

Más respuestas (1)

Img(200 > Img & Img > 30) = 200;

3 comentarios

@David Can you help me with the functions too, as in i don't know what kinda functions to use in MATLAB or how to use it.
That is probably more general than you intended, but your question was very general. What kinda functions to achieve what goal?

Iniciar sesión para comentar.

Categorías

Preguntada:

el 17 de Jul. de 2015

Editada:

el 24 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by