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.
It should compile fine using commercially available C/C++ compilers. The software works on 8-bit, gray scale images in TIFF and BMP file formats. Inexpensive programs are available to convert almost any image into one of these formats. Chapter 0 introduces the C Image Processing System.
Function stbi_load returns a pointer to an unsigned char* buffer. The size of this buffer is width * height * channels . The image data is stored in the buffer in row order, i.e., the first width * channels bytes belong to the first row of image. The following code sets the first 10 rows of the input image to black.
Python is one of the widely used programming languages for this purpose. Its amazing libraries and tools help in achieving the task of image processing very efficiently.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With