10

I want to learn image processing in C++, but I don't want to use any 3rd party library for image manipulation. Use of library for displaying the image(s) is okay, but all manipulations are to be done manually.

Please point me to some good tutorials. I'm a beginner in this field, so I also need to know how to display an image.

AndroidLearner
  • 4,500
  • 4
  • 31
  • 62
Harshil Sharma
  • 2,016
  • 1
  • 29
  • 54
  • You want to manipulate images without using a premade library? You have a very, very long road ahead of you. There's not going to be a tutorial for that. You're going to have to read the JPG specification, understand the theory behind imagine manipulations (unless you're doing simple things like cropping), and then apply those manipulations to the specific format of JPG. And then you'll need to repeat for PNG, GIF, etc. – Corbin Jul 15 '13 at 06:06
  • If your target is image *processing* you should at least also use a library to load images from various container formats such as png, jpeg, tiff, ... . These in itself have nothing to do with processing. Next to that this question is obviously way too broad, use google. – KillianDS Jul 15 '13 at 06:11
  • If your main objective is to learn digital image processing, I suggest you start by using Matlab instead of C++. – Korchkidu Jul 15 '13 at 06:17
  • Would a look at http://www.boost.org/doc/libs/1_54_0/libs/gil/doc/index.html help? – Jan Herrmann Jul 15 '13 at 06:24
  • why not using a premade lib and only use their load/store facilities? That way you can be sure to rely on working data structures in case you are facing problems.Take the Gonzales/Woods/et al book as mentioned below. – ogni42 Jul 15 '13 at 09:01
  • @ogni42; I'm considering OpenCV for the purpose. – Harshil Sharma Jul 15 '13 at 09:08

2 Answers2

7

Seems you lack basic knowledge of Digital Image Processing, I recommand to you this book. Digital Image Processing (3rd Edition) Rafael C.Gonzalez / Richard E.Woods http://www.amazon.com/dp/013168728X

For basic operation using OpenCV(which I am familiar with), here is an example:

/*
function:image reverse
*/  
#include "stdafx.h"  
#include <stdlib.h>  
#include <stdio.h>  
#include <math.h>  
#include <cv.h>  
#include <highgui.h>  
int main(int argc, char *argv[])  
{  
    IplImage* img = 0;   
    int height,width,step,channels;  
    uchar *data;  
    int i,j,k;  
    if(argc<2)  
    {  
        printf("Usage: main <image-file-name>/n/7");  
        exit(0);  
    }  
    // Load image   
    img=cvLoadImage(argv[1],-1);  
    if(!img)  
    {  
        printf("Could not load image file: %s\n",argv[1]);  
        exit(0);  
    }  
    // acquire image info  
    height    = img->height;    
    width     = img->width;    
    step      = img->widthStep;    
    channels  = img->nChannels;  
    data      = (uchar *)img->imageData;  
    printf("Processing a %dx%d image with %d channels/n",height,width,channels);   
    // create display window  
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);   
    cvMoveWindow("mainWin", 100, 100);  
    // reverse image 
    for(i=0;i<height;i++)   
        for(j=0;j<width;j++)   
            for(k=0;k<channels;k++)  
                data[i*step+j*channels+k]=255-data[i*step+j*channels+k];  
    // display reversed image  
    cvShowImage("mainWin", img );  
    cvWaitKey(0);  
    cvReleaseImage(&img );  
    printf("height=%d  width=%d step=%d channels=%d",height,width,step,channels);  
    return 0;  
}  
lulyon
  • 6,707
  • 7
  • 32
  • 49
  • I don't want to go in details of JPEG or other containers. What I want to do is: load up the image (use of 3rd party library will be better for this IMO), then apply manual modifications to pixel data (the RGB values) to perform various manipulations. – Harshil Sharma Jul 15 '13 at 06:57
  • @HarshilSharma Just use the basic part of 3rd party graphic library, like OpenCV, CXImage, as far as I know. – lulyon Jul 15 '13 at 14:02
  • @HarshilSharma For "manual modifications to pixel data", please check the updated answer with one OpenCV example. – lulyon Jul 15 '13 at 14:22
0

Try CImg (it's entirely self-contained) - http://cimg.sourceforge.net/

Francesco Callari
  • 11,300
  • 2
  • 25
  • 40