Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How can I make the background of an image black and all the objects present are white? I have tried the AbsDif and thressholding its result but it considers the lighting very much.

Here is the sample image : http://stackoverflow.com/questions/19699687/algorithm-to-count-people-in-a-crowd[^]

Please help.
Posted

1 solution

Try Canny filtering first to detect edges

VB
Dim img As New Image(Of Bgr, Byte)("img.jpg")
Dim imgCANNY As Image(Of Gray, Byte) = img.Canny(90, 70)


Then make Binarization

VB
Dim img_BINARY As Image(Of Bgr, Byte) = img.ThresholdBinary(New Bgr(100, 100, 0), New Bgr(0, 100, 100))


Convert it to C# and play with numbers to get best result, also u can try different filtering to get better result
(Sobel, Laplace, Sub, EqualizeHist, SmoothBilatral)

Additional information here: www.emgu.com/wiki/

Best,
Nick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900