473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

C#-APP: Program that detects difference (in color) between images.

Hi, I'm having a lot of troubles trying to build a function to figure out the difference (in color) between two images.


I've tried to build something similar with the ImageMagick API, but I've had many troubles compiling a DLL from the libraries.
I am also unfamiliar with the .net libraries, but I've been reading up on MSDN.

I know how the basic flow of the program should go (I think), I've been having trouble executing the steps.

Load ImageA
Load ImageB
Take the difference (absolute value of the difference in color between the images)
Change Channels of this new image (give color to the masking)
Save this as a different image. (Temporarily: To be used as a mask later.)
Change the channels of this image (To give it color)
Overlap the image with the mask on top
Save the image.



Here is what I have so far.

//Load ImageA
Image ImageA = new Image.From("ImageA.jpg");
//Load ImageB (Assume same size)
Image ImageB = new Image.From("ImageB.jpg");
//Take the difference of the images: If there is a visible difference, display some white, otherwise show black.
//How would I do this for colored images?
//Save this image. (Temporarily [should I turn this into a BLOB?])
ImgTmp = Bitmap("[????].jpg");
//Change Channels of this new image (This section of the code is taken/modified (badly) from <http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx>. I admit now that I don't know what I'm doing.)

unsafe
{
byte * p = (byte *)(void *)Scan0;

int nOffset = stride - b.Width*3;

byte red, green, blue;

for(int y=0;y < b.Height;++y)
{
for(int x=0; x < b.Width; ++x )
{

blue = p[0];
green = p[1];
red = p[2];

p[0] = p[1] = p[2] = (byte)(1 * red
+ 0 * green
+ 0 * blue);

p += 3;
}
p += nOffset;
}
}

//Overlap the image, onto ImageB.
//(Don't know how to do this in the way I want)

//Save Resulting Image.
Final.Save("[Filepath]\Final.jpg", System.Drawing.Imaging.ImageFormat.jpg);
----------------------------------

Please correct me if anything (read: EVERYTHING) is wrong, or a location of a properly functioning Magicknet DLL.

Again, I am learning, so I could use a lot of help on this.

Thanks!
Jan 28 '08 #1
1 2767
Nevermind: I got it to work! =d
Jan 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Galey | last post by:
I have a VB.NET application running on Windows 2000 Pro. I have a DeskJet 5550 printer, with the Windows default setup specifying to print in grayscale. From a 3rd-Party DLL called QuickPDF, I...
15
by: Geoff Cox | last post by:
Hello I have following type of code in the header function pre_load_pics() { if (document.images) { var image1 = new Image(400,265); image1.scr = "pic1.jpg";
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
7
by: tiger786 | last post by:
I am new to programming and studying basics in college .Can somebody write a program on this? The program should monitor a possibly infinite stream of characters from the keyboard (standard...
4
by: Kevin D. Smith | last post by:
I'm trying to get the difference of two images using PIL. The ImageChops.difference function does almost what I want, but it takes the absolute value of the pixel difference. What I want is a two...
8
by: KYAW KYAW OO | last post by:
Dear All, Now, I am stuck above question so long and I would like to get Red, Green and Blue as unsigned char * each from unsigned char * of 24 bit BMP Color images. e.g unsigned char *...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.