Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, February 26, 2013 12:35:25 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


The concept of contrast of a particular image can have multiple meanings, but they usually revolve around the ability to distinguish objects in the image. However, if you have 2 similar images, like the same object photographed by 2 devices from the same angle, you can get a measure of which one has the "higher" contrast value.

In general, a higher contrast image will have a greater spread of the histogram curve, since this will mean the contents of the image have more differences in their intensities, which leads to greater ability to distinguish objects.
You can use StatisticsInformationCommand Class to get the properties of the histogram of the image and detect which one has higher contrast based on which image has a higher standard deviation.
For an example, see the following code which was tested using v18 of LEADTOOLS .NET classes (but other versions should work too):
=====================================
RasterImage img1 = codecs.Load(fileName1);
StatisticsInformationCommand cmd1 = new StatisticsInformationCommand(RasterColorChannel.Master, 0, 255);
RasterImage img2 = codecs.Load(fileName2);
StatisticsInformationCommand cmd2 = new StatisticsInformationCommand(RasterColorChannel.Master, 0, 255);
cmd1.Run(img1);
cmd2.Run(img2);
if (cmd1.StandardDeviation > cmd2.StandardDeviation)
{
   MessageBox.Show(fileName1 + " likely has higher contrast");
}
else if (cmd1.StandardDeviation < cmd2.StandardDeviation)
   MessageBox.Show(fileName2 + " likely has higher contrast");
else
   MessageBox.Show("Standard deviation is equal");
=====================================

File Attachment(s):
contrastCompare.png (782kb) downloaded 60 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.107 seconds.