2
$\begingroup$

What are my options for Open Sourced Image Processing functionality on a Raspberry Pi?

So, I am referring to the old-school processing, using operators like open/close/erosion/dilation/threshold/convolution etc.

I am not looking for neural network based processing.

Bonus points if it has a Python interface, but C will work as well.

In the 1990s, in University I was using Scil Image for this stuff, and I wonder what the modern equivalent for it is?

$\endgroup$
1
  • $\begingroup$ I don’t have experience with Scil Image (staff.fnwi.uva.nl/d.c.koelma/isis/projects/scilimage.html), and didn’t mention it in my answer, but I think ImageJ is similar enough to be familiar, and that’s the one I mentioned. A few projects that have been active since the 1990s are still running now, and could be a good way for you to get started. There are some commercial libraries with great interfaces, but they’re pricey. $\endgroup$
    – Rethunk
    Mar 22 '20 at 14:41
2
$\begingroup$

Python has a lot of import libraries for image processing, and they are running on platforms that support Linux, such as Raspberry Pi.

Pi runs with ARM based processors, and every limitation of that CPU (especially on SIMD floating point ops) is also a limitation for image processing.

Pi also comes with a dedicated hardware GPU which can be used to accelerate certain image processing (computer graphics) functionality (in addition to its image/video encode and decode functionality)

Pi also comes with built in camera interface that would enable raw processing of camera data, using available Python libraries.

$\endgroup$
3
  • $\begingroup$ For the original question, when do you think floating point operations would be relevant to the image processing algorithms described? Floating point can be completely avoided in many cases. If you have image processing experience, do you have a particular library you would recommend to the poster? $\endgroup$
    – Rethunk
    Mar 22 '20 at 14:43
  • $\begingroup$ @Rethunk No need to restrict the range of operations that he would perform on his image processing task. Apart from what he wants, not every thing is possible with 8-bit width. There are many advanced DSP image processing algorithms that won't run on 8-bit integer arithmetic.So he would either use wider fixed point or an FPU if available. I can write my own C and/or (intel) ASM code for very low level image processing tasks. Nowadays everybody offers his own library ;-) Not using much but OpenCV, OpenGL, intelPrimitives, Matlab etc. are well known examples. Cannot recommend anything exclusive. $\endgroup$
    – Fat32
    Mar 22 '20 at 21:01
  • $\begingroup$ fair enough response, and thanks for adding more detail. The poster appeared to be looking for just the next step up. With your reply and various other info here, I think there will be enough for the poster to move on. I’m curious to see his next question. $\endgroup$
    – Rethunk
    Mar 23 '20 at 1:49
2
$\begingroup$

I would recommend three approaches:

  1. Try your own implementations first, especially if you haven’t written image processing code in a while.
  2. Google “Python image processing library.” There are a number of choices, and you know enough to pick what’s right for you. Opt for simplicity and usability first.
  3. Install OpenCV on a Pi. Don’t worry about performance; a Pi can do much of what you need.
  4. Look at other 3rd party image processing libraries besides OpenCV.

Many years ago, I wrote a simple object-tracking app on a PC104 processor card using algorithms I’d written myself. I believe the RPi 4 may outstrip that old PC104 processor.

Someone completely new to image processing should find a simple app like ImageJ to tinker with different processing techniques to see what they do. Developing a gut sense for what works and what doesn’t is a good start. But it sounds like you already have experience.

As long as you can get an image into an array, you can write all sorts of traditional vision algorithms. This is worth doing. I’ve interviewed MANY job applicants who tout their skills with modern image processing, machine learning, etc., but who couldn’t answer simple questions about fundamental image processing techniques. Some folks become very familiar with a particular package, but then don’t understand the underlying functionality well enough to be of much use—and certainly not at the salary they expect.

You can run OpenCV on a Raspberry Pi. If you have an older Pi, consider getting the most recent version with more memory.

https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/

You’ll find a lot of resources related to OpenCV. It’s free. It’s useful to a number of people. There’s an O’Reilly book about it. But whether OpenCV is right for you in the long term is best left for another discussion. Beware those who say you MUST learn OpenCV, that everyone uses it, etc. I’ve been in this field a long time, and I’d simply suggest a bit of caution when approaching OpenCV or any other package.

OpenCV has adherents who “know” it and have used it for years, but may not know how the underlying algorithms work. That’s actually okay—we don’t all have to be equally interested in how every image processing algorithm works, or how some open source contributor decided to implement this or that functionality. Using high-level functions is a good way to tinker with a number of algorithms in relatively little time.

There are other open source image processing packages. I’d suggest finding a few, identifying the simplest that does what you need and that works on a Pi, and then go with out. Struggling with an overly complex install just to use a tiny fraction of some library’s functionality can be frustrating.

ImageJ is simple and extensible, and you’d recognize some of the functionality. https://imagej.nih.gov/ij/

I’ll mention some other guidelines. Learning image processing goes beyond picking a library of functions.

Even if you’re just tackling some personal projects, set some basic specs. For example, let’s say you want to write a pipeline of image processing functions that take an image, remove some of the noise, and then count a number of objects. Ask yourself how long you can allow this to process. Then give it a try! For example, if you want it to run in 250 milliseconds, but it takes 600 milliseconds, then there’s a good chance a few simple optimizations will help: process only some of the image; simplify the morphological operator; or the like.

To repeat an earlier point: start simple. See if you can get an image into memory. Try running a ready-made app. Spend a bit of time with a textbook like Gonzalez & Woods to learn step by step.

Pick an image processing application beyond what you’re capable of tackling now, and gradually create ever more complete solutions.

Learn a bit about cameras and lenses. Just a bit! For example, if you can just fit an object 0.5 meters long into an image, where does the camera need to move to fit an object 1.25 meters long in the same orientation?

Also, feel free to send me a private message or start a dialogue here in the comments. Most of my StackOverflow answers are related to getting people started in the field.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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