|
-
Oct 9th, 2005, 09:49 PM
#1
Thread Starter
Lively Member
[RESOLVED] Find the difference in two images.
If there's a built in function in the .NET framework for this, that would be really cool, however, I don't count on that happening, so I've been thinking about how to do such a thing.
I think that if I can figure out how to get and/or change the color value (in any format at all) of a specified pixel of a specified picture, I would be able to do it myself. For example if there is a function like GetPixel("C:\image.jpg", 30, 87) that might return a rgb value, or the color value as a long
If anyone has any help it would be greatly appreciated. Thanks in advanced!
Last edited by deranged; Oct 11th, 2005 at 12:46 PM.
-
Oct 9th, 2005, 11:47 PM
#2
Re: Find the difference in two images.
no builtin function obviously
The bitmap class has setpixel and getpixel methods. so if you have an Image object, you could do:
Bitmap bmp = (Bitmap) Image;
then bmp.SetPixel(...
SetPixel and GetPixel are slow though, so keep that in mind. You could access the pixels using unsafe code and pointers also. If you are interested in doing that (much harder, especially if you dont know what you're doing), look up Bitmap.LockBits...
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 10th, 2005, 11:19 AM
#3
Re: Find the difference in two images.
Bear in mind that you will have to load a JPG, because of the compression, but a bitmap file you could edit directly.
-
Oct 10th, 2005, 12:34 PM
#4
Thread Starter
Lively Member
Re: Find the difference in two images.
 Originally Posted by penagate
Bear in mind that you will have to load a JPG, because of the compression, but a bitmap file you could edit directly.
For the time being, I'm pre-loading every image into a picturebox. So far it's working great. However, I'm a little worried about how this will perform as far as speed goes.
My final intention is to make a program that will detect motion from a webcam feed. I'll do this to detect change in any two chronological pictures. I still have to learn how to grab a pic from the webcam, but that's a whole different topic to be discussed later.
Last edited by deranged; Oct 10th, 2005 at 12:40 PM.
-
Oct 10th, 2005, 12:48 PM
#5
Fanatic Member
Re: Find the difference in two images.
If you want to detect movement like that you don't even need to check every pixel, just check every 5th or 10th pixel on both axes.
The way I did it was to have a class level array that would hold the colors of the sample points. Then compare them and replace them with the new values each time. This way you don't have to keep the previous image in memory.
You could just create it using the GetPixel SetPixel functions and replace that with unsafe code later, when you feel up to it.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Oct 10th, 2005, 02:03 PM
#6
Thread Starter
Lively Member
Re: Find the difference in two images.
 Originally Posted by grilkip
If you want to detect movement like that you don't even need to check every pixel, just check every 5th or 10th pixel on both axes.
The way I did it was to have a class level array that would hold the colors of the sample points. Then compare them and replace them with the new values each time. This way you don't have to keep the previous image in memory.
You could just create it using the GetPixel SetPixel functions and replace that with unsafe code later, when you feel up to it.
I had the array idea in mind for sure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|