Showing posts with label Image editors. Show all posts
Showing posts with label Image editors. Show all posts

How to convert IplImage to a matrix in OpenCV


Getting a digital image into numbers can be very handy for your image processing. In this post i will brief just that. I am a beginner in OpenCV and i found it very difficult to find material to do this. I was looking for storing a 8-bit image, 3 channel image into a 3D matrix. That's the method i am going to explain in this post.

Before i get on with the implementation, i would like to brief about the matrix structure that we are going to use. Its a 3D matrix; the row and column values represent the respective X and Y co-ordinates of the image. That is each value in the matrix represent a pixel. I am considering a 3 channeled image, so each pixel will have 3 channel values i.e for BGR. For more info on the matrix basic you can refer this link.

Following is the method I used..

First load a 8-Bit image with 3 channels RGB and create define a matrix structure accordingly.

          IplImage *img = cvLoadImage( "cataract.jpg");
    CvMat *mat = cvCreateMat(img->height,img->width,CV_32FC3 );

Next use the cvConvert function. cvConvert is a Macro provided by OpenCV which is the same as cvConvertScale() but is conventionally used when the scale and shift arguments will be let at their default values. 

           cvConvert( img, mat );

That does the work! Now your IplImage is stored into the matrix. You can retrieve the matrix values just by specifying the corresponding X,Y co-ordinate values in the cvGet2D function. I have used a for loop to print the RGB values of a small portion of the image.


        for(int i=0;i<10;i++)
        {
          for(int j=0;j<10;j++)
            {
               CvScalar scal = cvGet2D( mat,j,i);
               printf( "(%.f,%.f,%.f)  ",scal.val[0], scal.val[1], scal.val[2] );
            }
          printf("\n");
        }

cvScalar function is used to define a variable that stores the RBG value retrieved. You can check the OpenCV Reference links for some more tutorial links on OpenCV.

Please leave a comment so that know if this post is helpful or not. Also mention if any changes is required. It could help others :)



Luminance HDR


Are you a photographer? Then Luminance HDR is the kind of software you'll be interested in! Luminance HDR being an open source project, is an graphical user interface application that aims to provide a workflow for HDR imaging.

              Now you don't know what's a HDR imaging??! :O CLICK HERE

Luminance HDR supports the following LDR formats:
--> JPEG, PNG, PPM, PBM, TIFF(8bit)

Luminance HDR is available for Linux, Windows an Mac OS X. Here i'll be providing download just for Windows version. For more technical info on Luminance click here

A tutorial for doing HDR photography

Download
Luminance HDR for Windows

You can also help Luminance HDR as a developer or as a resource organizer. Please contact for more info.



Please leave a comment so that know if this post is helpful or not. Also mention if any changes is required. It could help others :)

Pencil :2D animation Tool


Pencil is an Animation/drawing Toolkit compatible with Windows Mac and Linux OS. This is an open-source software and is available for free. It lets you create traditional hand drawn animations (cartoons) using both bitmap and vector graphics.

Pencil USER MANUAL is also available.

Download:-
size 5.29mb

GIMP 2.6

GIMP on Mac OS


GIMP is the GNU image manipulation program. This is a freely distributed open-source software fro performing image manipulation. Photoshop is a well known another image manipulation software. GIMP provides the same experience free of cost. Editing image gets a lot simpler!!

GIMP 2.6 works on many operating systems, in many languages. GIMP 2.6.6 is a bug-fix release in the stable GIMP 2.6 series.

Check out the feature overview and screenshots of GIMP 2.6.6


Download:-
size 15.32mb
GIMP 2.6.7 for Windows