Applying median filter to a picture ...
Somebody has a working median filter for gray and color images written in C or C++ and can share it ? I made a simple QT interface to load picture, now i want to make a median filter to that picture. But i have no ideer how to do that :( Don`t have alot experience in picture processing.
I can also give the code for my interface if asked, im willling to share it (well its not much anyway). Gratefull for help. |
Take a look at ImageMagick:
http://www.imagemagick.org/Magick++/ http://www.imagemagick.org/script/magick-wand.php http://www.imagemagick.org/script/magick-core.php 'Hope that helps .. PSM |
I have to use language C++ or C (with standard libs) and QT to implement them to my GUI. So extra software or programs dont count. Its a school project, which i am scared i am not gona make without some help :cry:
Well here is what i made so far: main.cpp Code:
#include <QApplication> Code:
#ifndef IMAGEVIEWER_H Code:
#include <QtGui> Im not lazy in any way, i just cant figure this one out :( Never had a spot for C++ or C, and never we done any work on image processing so i even dont have the right knowledge how things go. If you can help, well probably thx is not enough, but you would realy help me out. Well here it goes. thx. |
Of *COURSE* you want to use a library like ImageMagick, if at all possible.
When you're a professional, do you think you'll have the luxury of re-inventing the wheel? The whole beauty of Open Source is that you can see how somebody did something (instead of just buying or licensing closed, "black boxes" like in the commercial world) which (in theory, at least) will educate and empower you to ultimately make your own contributions back to the open source community. Please ask your professor if you can use a library like ImageMagick (or GTK+, or any number of other alternatives) in your project: a) If he/she says "yes", please make the extra effort to look into the ImageMagick source and figure out how the particular filter you're using actually works. Make sure your professor knows you took that effort. b) If he/she says "no", then get a book from the library on "Image Processing 101", read what you need, and post back any specific questions you have about the median filter (or convolution filter, or color quantization, or whatever you happen to be working with). If you wind up having to "reinvent the wheel", then take it one piece at a time, and post back specific questions about that one piece. 'Hope that helps .. PSM |
I have to implement it myself into that code i posted. So it works in my QT GUI i made. Well its not so hard i know how median filter works. I am just stuck, how do i acess pixels with QT so i can use them in my algorithm. So i have to acess pixels. Maybe someone can wrote me a simple example of acessing pixels, and then making dunno each pixel -5 and then write them back to the picture, so i get how i do those steps, i can do the rest myself.
thx. |
Real question: "how to access pixels in Qt?"
Hi -
So the real question is: Quote:
Lots of ways, including: http://doc.trolltech.com/3.3/qpixmap.html http://doc.trolltech.com/3.3/qcanvaspixmaparray.html http://www.jtz.org.pl/Inne/QT-Tutorial/qimage.html http://dot.kde.org/1098950311/ |
Can you make some simple example how to implement that, im not the brightest when i have to read some manual for some programming language, and not realy good at QT or C++ so i understand hard whats going on, good in java but thats a completly diffrent approach :S
Thx. |
Ok got filter mediana for black and white pictures.
/*************************************************************************** * Func: median_filt * * * * Desc: median filters an image using a block mask * * * * Params: source - pointer to image in memory * * cols - number of columns in image * * rows - number of rows in image * * filename - name of output file * * side - width of block * ***************************************************************************/ void median_filt(image_ptr source, int cols, int rows, char *filename,int side) Now i need to supply it with these parameters. I got cols and rows from image.width(); and image.height(); filename i specify, it will be filename to which picture will be saved. Now i dunno how do i get width of block in QT, or what width of block actualy is. And source says its pointer to image in memory. Can i make a pointer in QT to image to memory (notice that the algorithm for mediana is written in C, compiles fine), or how do i make a pointer to image ? If i have QImage image; How can i make pointer to location of that ? Thx. |
All times are GMT -5. The time now is 03:16 PM. |