473,698 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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("Ima geA.jpg");
//Load ImageB (Assume same size)
Image ImageB = new Image.From("Ima geB.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/csharpgraphicfi lters11.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.ImageFo rmat.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 2783
CompletelyUseless
2 New Member
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
1238
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 specified monochrome and print the document. It ignores the monochrome flag and prints in color, so I figured QuickPDF needs to go back to the drawing board. But then I tried transferring the document into a MemoryStream and printing it using...
15
2327
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
8531
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 like "gcnew is undeclared error",how to deeclare 'gcnew" and when i am using in runtime to change the size of images in imagelist in listview control in .net(forms application) by chnging one trckbar(like tb1->Value),
3
3824
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 nutshell when testing my ASP.NET (localhost) apps images randomly don't load on the page. Examining the IIS logfile shows the missing images give 401 or 403 errors. Here's an example - 10:15:47 127.0.0.1 GET...
7
2585
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 input). If it detects the sequence "ccc" it outputs a "0". If it detects the sequence "cdc" it outputs a "1". DO NOT detect sequences within sequences. The program should exit cleanly when it detects an End Of Input. For example:
4
3633
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 color output image: black where the image wasn't different, and white where it was different. Right now I get black where it wasn't different, and abs(image1-image2) where it was different. It would be nice if I could specify the colors for...
8
7588
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 * image = new unsigned char ; unsigned char * red = new unsigned char ; unsigned char * blue= new unsigned char ; unsigned char * green = new unsigned char ;
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.