RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Display Image Attributes with OpenCV

Here is a simple program to display image attributes like width, height, size and etc. This program assumes that you have OpenCV library alredy installed on you system.

#include <iostream>
#include <iomanip>
#include "cv.h"
#include "highgui.h"

using namespace std;

int main( int argc, char** argv )

{

// Create an IplImage object *image 
IplImage *image = cvLoadImage( argv[1]);

// Display Image Attributes by accessing a IplImage object's data members

cout << left << setfill(' ') <<  setw(15) << "Image filename:" << argv[1] << endl;

cout << setw(15) << "Width:" <<  image->width << endl;
cout << setw(15) << "Height:" <<  image->height << endl;

cout << setw(15) << "Pixel Depth:" <<  image->depth << endl;
cout << setw(15) << "Channels:" <<  image->nChannels << endl;

cout << setw(15) << "Width Step:" <<  image->widthStep << endl;
cout << setw(15) << "Image Size:" <<  image->imageSize << endl;

return 0;
}

Compile with:

g++ `pkg-config opencv --cflags --libs` imageattr.cpp -o imageattr

OUTPUT SAMPLE:

./imageattr re_dsc00056.jpg
Image filename:re_dsc00056.jpg
Width:         1148
Height:        644
Pixel Depth:   8
Channels:      3
Width Step:    3444
Image Size:    2217936

Share this linux post:

Submit Display Image Attributes with OpenCV in Delicious Submit Display Image Attributes with OpenCV in Digg Submit Display Image Attributes with OpenCV in FaceBook Submit Display Image Attributes with OpenCV in Google Bookmarks Submit Display Image Attributes with OpenCV in Stumbleupon Submit Display Image Attributes with OpenCV in Technorati Submit Display Image Attributes with OpenCV in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download