5

enter image description here

What thresholding techique should i apply for the image in order to highlight the bright regions inside the image as well as the outer boundary..

The im2bw function does not give a good result

Help!!

Edit: Most of my images have the following histogram

enter image description here

Edit: Found a triangle threshold method that suits my work :)

enter image description here

vini
  • 4,657
  • 24
  • 82
  • 170
  • If your goal is to improve the contrast on the image, then you should use a tone curve http://www.mediachance.com/pseam/help/curves.html. – Simon Bergot Feb 09 '12 at 16:56

2 Answers2

5

Your question isn't very easy to answer since you don't really define what a ideal solution should accomplish.

Have you tried im2bw(yourImage, 0.1); ? I.e using a threshold for what parts should be black and waht parts shouldn't. I got descent results with that (depending on what the purpose is of course). Try it and if it isn't good enough, tell us in what way you need to improve it and i will try to help with some more advanced techniques!

EDIT: Using threshold 0.1 and 0.01 respectively, perhaps something ~0.05 should be good?

Using threshold 0.1

Using threshold 0.01

Niclas
  • 1,220
  • 6
  • 12
  • Thanks @Niclas I got this result however this isn't the only image i am working on... i ll put a histogram that most of my images show .. – vini Feb 09 '12 at 13:59
  • Choosing a threshold adaptively would be best in my case – vini Feb 09 '12 at 14:06
  • @vini you have to define what are you trying to do. Maybe choosing the threshold adaptively is the solution. But without more details it is difficult to suggest a solution. How do you define "bright region"? – Simon Bergot Feb 09 '12 at 14:10
  • well am finding skin defects in fruits this maybe scald , rot , hail etc – vini Feb 09 '12 at 14:17
  • 2
    Perhaps you should look into the function `graythresh()`. Maybe it can help you to accomplish a adaptive threshold that suits your needs. Also look into using `adapthisteq()` before using graythresh to "normalize" your images first.. If this won't work either i think you need to provide som more detail.. – Niclas Feb 09 '12 at 14:23
  • @vini What I meant was: what do you want to do with the binary image you wish to compute? – Simon Bergot Feb 09 '12 at 14:26
  • @Simon Well nothing actually thought thresholding would yield better results for some of my images where defects aren't that visible as the final step for segmentation – vini Feb 09 '12 at 14:43
  • @vini If you say that you do nothing with the result, then I wonder what is your actual problem. If you say that you want to check the image with your own eyes, then thresholding is not the best option. So what do you want to do with the thresholded image? – Simon Bergot Feb 09 '12 at 16:53
  • Am sorry @Simon segmentation of the defect is my goal is thresholding good for that purpose? – vini Feb 09 '12 at 17:03
  • 2
    Well ultimately if you want a binary segmentation you will have to use thresholding at some point. – Simon Bergot Feb 09 '12 at 17:25
1

It sounds like what you want to do is ''image segmentation'' (see http://en.wikipedia.org/wiki/Segmentation_(image_processing) ).

Most methods are based on the Chan-Vese model which identifies the region of interest by solving an optimization problem involving a level set function. Since you're using matlab, this code: http://www.stanford.edu/~tagoldst/Tom_Goldstein/Split_Bregman.html should do a good job of finding the regions you are interested in.

dranxo
  • 3,348
  • 4
  • 35
  • 48