Hi
I am engineering student, currently working in image processing.
I have big issue in understanding few basic concepts in programming. To be frank I am beginner, so my question will look silly, so please tolerate with me and if anyone can help me it would be much use full for me.

I started learning image Process using Matlab. it very easy using the Matlab function for ie : it need only one single line to open image. But my problem is I want to create the same algorithm in C or C++.

But if I want to create the same algorithm for mobile application I need to convert in to c or c++.But in c/c++ it will take 10 to 15 line for a single image open process.

So I am confused here can we use open CV and create the same mobile application? Or what is the use of open CV. And even I saw there are many different libraries for image processing, so I am confused in which way to go , what is the difference in all this libraries available out there and how to choose the right way for my need.

The below site give few sample http://www.xdp.it/cximage.htm

So please let me know, what is the difference between writing a program in C/C++, or using Open CV in C/C++ . Can we use both codes for creating application?

Thank You
kumar

Dani AI

Generated

Summary and practical guidance for the Matlab→C/C++ (mobile) path — clarifying points that follow the discussion by , and .

Matlab is ideal for fast prototyping; production code for constrained devices separates two tasks: (A) the algorithm itself and (B) image I/O, memory layout and performance plumbing. Libraries remove most of task (B) and provide many vetted implementations for (A), but bring dependency and size tradeoffs. That tradeoff is the core decision to make.

Important portability gotchas and correctness checks

  • Indexing and layout: Matlab uses 1‑based, column‑major arrays; C/C++ libraries like OpenCV use 0‑based, row‑major storage. Adjust index math and loops accordingly.
  • Types and ranges: Matlab often uses double in [0,1]; many C/C++ image APIs use uint8 in [0,255] or float arrays. Explicit casts and scaling are required.
  • Color order: imread variants differ — some libraries return BGR by default while Matlab uses RGB; verify channel order before comparing outputs.
  • Numerical vs visual equality: test with quantitative measures (RMSE, PSNR) and visual checks; small numeric differences are normal after porting.

A recommended porting workflow

  1. Keep the Matlab version as the reference oracle and create a small test set with expected outputs.
  2. Map Matlab ops to library functions where possible; if a function is missing, reimplement and validate against Matlab.
  3. Start on desktop using the chosen C++ library to iterate quickly, then cross‑compile for the target (static vs shared, strip symbols, module selection).
  4. Profile on target hardware, reduce allocations, reuse buffers, and replace hot inner loops with optimized primitives or architecture intrinsics only when needed.

When to use a library vs hand-roll code

  • Use a library when many common algorithms or fast development is needed.
  • Hand-roll only when binary size, memory, or licensing requires it, or when the kernel is tiny and extremely performance‑sensitive.

Useful references (textbook/handbook titles to search): Digital Image Processing (Gonzalez & Woods), Learning OpenCV (Bradski & Kaehler), and Szeliski’s Computer Vision text. A minimal OpenCV-style C++ example for reading and gray conversion:

#include <opencv2/opencv.hpp>

cv::Mat img = cv::imread("in.jpg", cv::IMREAD_COLOR);
cv::Mat gray; cv::cvtColor(img, gray, cv::COLOR_BGR2GRAY);

Recommended Answers

All 7 Replies

Member Avatar for Member #489967

The libraries provide functions that allow you to read and write image files and get easy access to the pixel data in a format that makes it easier for your programs to manipulate it. It let's you write code to analyze images, modify images, or produce your own images without worrying about how the data is formatted, compressed, etc., for storage in a file.

In addition to that, OpenCV also has many image processing functions built-in. Many of the algorithms that you want to learn are already implemented in OpenCV. Whether this is good or bad is up to you. You may find it helpful to see how your output is supposed to look, you may find it useful to be able to compare the running speed of your implementation with theirs, etc.

I'm not familiar with CxImage but based on a quick glimpse it looks like it would be very convenient for opening and writing many image formats. It seems to provide much less of the higher-level functionality than OpenCV but at the same time it's probably easier to use so it might suit your purposes very well.

If you only want to work with .bmp files, here's a link to something that I recently found, EasyBMP, which is very small and super easy to use but is only for bitmap files and it provides almost nothing in terms of image processing. All it does is get you easy access to the data in the image file -- you do all of the higher level processing in your own code.

Hi

Thank You, from your reply i was able to understand few thing, So when it comes to develop a new image processing techniques we can use Open CV in a much easier way and see the result in system and it reduces the time to develop a full set of code in 100 and 200 lines in C/C++.

But if we need to create a application for a particular device like mobile or digital camera we need to write in C or C++ with out using this libraries and it will take 100 to 200 likes depending up on our requirements is it right ?

So all this available libraries make our code easy and see the result immediately with out any difficulties in system...

OK once again thank You, if u can refer me a book that give the basic image processing idea, it will be help full, i don't want to use open CV , i want to learn pure image processing using C or C+++

Kumar

But if we need to create a application for a particular device like mobile or digital camera we need to write in C or C++ with out using this libraries and it will take 100 to 200 likes depending up on our requirements is it right ?

So all this available libraries make our code easy and see the result immediately with out any difficulties in system...
Kumar

I use OpenCV every day, and, yes, I think it is an awesome library. However, you should realize that using OpenCV introduces a large overhead because it is a very rich library. On my system, ( the main OpenCV library ) takes up 10 MB of space.

If you are just opening the image ( especially if you know the data format ), it would probably be better to use a smaller library. Of course, if you really are doing image processing, it may be excessive to implement the algorithms yourself.

What types of images are you opening? With which algorithm are you processing the data?

Hi

Currently i am using Matlab, but i need to convert the matlab code to C/C++, So that it will be sue full for a mobile application.
But the problem is i am not sure where we can use Open CV for such application.

Hi

Currently i am using Matlab, but i need to convert the matlab code to C/C++, So that it will be sue full for a mobile application.
But the problem is i am not sure where we can use Open CV for such application.

I found this on google: . Looks like using OpenCV for mobile devices is very doable.

Look at the, the , and google in general for some good examples of how to use OpenCV.

commented: Sounds good +12

Hi

Thank You for the link, it’s really nice , I will look into that and if I found anything interesting I will let you know.

can we create forms like in vb using c. and can we use buttons,textboxes and all..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.