Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a project in which I take a handful of images and coordinates, and combine them all into a single image based on those coordinates. (so not really image processing, just image layering/combining)

Also will take data that has text and shapes objects (squares, lines, circles), and coordinates/font-size and also layer those over the images to create one final image (png or jpg).

I will have to process hundreds of these on the fly as quickly and as efficiently as possible on a CentOS machine.

What language should I use?

  • Python
  • Java
  • C

I am biased toward Python because I want an excuse to learn it... so I'm leaning that way unless Java or C is at least an order of magnitude better. Please offer your opinions, or if I need to clarify my requirements more?

share|improve this question
1  
I C said the Python to his cup of Java. –  Mathew Foscarini May 14 '13 at 23:54
    
I think you could use ImageMagick for this - it has command-line tools, and bindings to many languages including python. –  Blorgbeard May 15 '13 at 0:10
add comment

closed as not constructive by MichaelT, BЈовић, Joris Timmermans, Bart van Ingen Schenau, Kilian Foth May 15 '13 at 11:44

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

up vote 3 down vote accepted

If you take Python, all the image manipulation will be effectively native code anyway — GD2, ImageMagick, PIL all are bindings to C libraries for image manipulation. The upside is that Python is a very good glue language, succinct, readable, and not very error-prone.

With Java, image manipulation most probably will be all pure Java. Performance-wise, it will probably as good as C if not better (current JIT is pretty good at profiling and optimizing). It will probably consume significantly more memory. Also, JIT becomes effective if the code runs for some time, so startup time of your app will be greater; this approach works best with servers.

With C, you probably will use a ready-made image manipulation library anyway, but your glue code will take 10x the effort to write and 10x the time to debug, unless you're an experienced developer writing C every day. The result has a chance to be very compact and fast, with fastest startup of the three.

So I'd clearly take Python. Don't optimize before you profile. If anything, a Python version would be a good prototype should you have to rewrite your program.

Also, if you have a couple of days to spend on learning a new language, Go might be a good compromise between speed (20-50% slower than C) and ease of writing (garbage collection, static typing, compact syntax).

share|improve this answer
    
+1, you can call the exact same library from C or phython, I know which one I'd choose . . . –  Wyatt Barnett May 15 '13 at 11:44
add comment

All of these languages work fine on CentOS, and all of them can do heavy duty image processing through readily available libraries. Choose the language you are most comfortable with and if you are equally comfortable with all of them, then choose the one with the libraries you find most convenient. Most image processing libraries for Python are basically C wrappers, the JVM is blazing fast, and C is... well, it's C. In a nutshell, performance is not something to worry about here, and all languages are equally well supported for Linux, so choose the one you are most comfortable with.

share|improve this answer
    
good comment, thank you. –  timh May 15 '13 at 3:04
add comment

For my Master thesis, I had to compare Python and Java for image processing on a Linux computer. The context was the analysis of video frames in order to follow white-cells, so the image processing part of the work was mainly shape detection and tracking.

I compared PIL and ImageJ, which prentends to be the fastest Java image processing library. Actually ImageJ was faster than PIL in my case. This library also provides a lot of features, at least for bio-chemical purpose.

The most important disavantage of ImageJ is probably the lack of useful documentation for some plugins: when I used it, I needed to deal with the javadoc, the user doc, and, occasionnally, the code itself.

The ImageJ library can be used as a standalone application, a scripted application or a real programming library. It provides an automated tool for parallelising the image processing.

Summing up, my advice is to create a small prototype in Java+ImageJ so that you can determine if it corresponds to your needs.

share|improve this answer
add comment

In my opinion you should first look at algorithms you are using rather than languages, the significance of language you have chosen will only matter in an edge case where you have run out of options after you have optimized your code to the max. Crappy algorithm written in C will be a lot slower than good algorithm in Python.

In heavy image processing popular practice seems to be, first prototype the algorithm in Matlab and then rewrite it in something else once it has been proven to work and algorithm is fast enough.

C will be the fastest of all, that is for sure, but implementation will be the most problematic of all.

In terms of Python vs Java, interpreted python will probably be slower than java, but you can run Python on JVM (JPython), that should narrow the gap or even remove it.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.