hi,
does anyone know how to write in C programming to open two images and subtract them to get a result ? please take note that the image is an grayscale image.
thanks.
hi,
does anyone know how to write in C programming to open two images and subtract them to get a result ? please take note that the image is an grayscale image.
thanks.
Last edited by valy_mil; 01-10-2008 at 09:50 AM. Reason: typing error
You need some sort of library that can read the image format you have - it may be part of your OS, or you may need some third party product [free or commercial]. Once you have something that can load the images and take byte by byte and subtract one from the other, and store the result as another image [or whatever you want to do with the result].
Of course, you CAN write your own routines to load an image, but I wouldn't recommend it.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
hi matsp,
u mean i need to apply some sort of library to load in the image?
i'm writing my program using Linux-Ubuntu. So izzit possible to use fopen to open an image?
by the way.thanks for the previous reply.
We all know a bit about writing in C - check. Images are just files with a particular format so - check.
"Substract" == subtract. Here, I need a much better explanation of what you want. Subtract the area of one from the area of the second one, subtract the light/dark value's from each other, what?
It would be best if you could load an example showing the two input and one output image to Photobucket, and paste the url here so we can see what you mean.
And of course, show us your work on this. We won't write your program for you.
If this isn't a programming assignment, you might want to check with Gimp and other image manipulators. They may well have a facility to automatically do that for you.
Last edited by Adak; 01-10-2008 at 03:48 AM.
Of course, you can use fopen() on an image file - the problem is that even the simplest of image files (such as Windows BMP's) aren't particularly easy to read straight away, and it gets even worse if the image is a TIFF, JPEG, PNG, GIF etc, as those have a more complex structure.
Since there are libraries [e.g. libjpeg] that allow you to build an application that can just load a JPEG image and then access the data directly, why bother with writing hundreds or thousands of lines of code to read the image, only to do a simple operation on the data loaded [if I assume correctly that you just want to subtract each pixel from one image from the corresponding pixel of the other image].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
hi matsp,
i want to convert the jpeg to grayscale bmp because as i know, Jpeg is a lossy compression format.
So you need to have a library that supports JPEG images and BMP, and then you need some algorithm for converting to grayscale [unless the input JPEG is a grayscale already].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
hi matsp,
i'm able to convert jpeg to grayscale bmp image, just when i want to process the image i dont know how to load in the image in my C code to process the image. Can u give some guide to me on this?thanks
Just google for "bmp file format". There's plenty of info out there.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
there's OpenCV, an open source computer vision and imaging library. Although if you look at my thread, I'm having some trouble getting it started in Dev-Cpp. Hope you have better luck!