Request image processing references for C/C++ // NDK

799 views
Skip to first unread message

Jim Graham

unread,
Jun 3, 2012, 1:21:45 PM6/3/12
to andro...@googlegroups.com
I'm looking for C/C++ image processing references for use with the
NDK. I've tried OpenCV, and so far, have had no luck, but I'll be
getting a new computer[1] in about a week, and will be able to use the
NDK now, and want to convert all of the Java-based image filters
to C or C++ using the NDK, which I'm certain will be MUCH faster.
:-)

Any good links to reference material (online) would be greatly
appreciated. Oh, and it needs to be something I can apply in a
paid app (i.e., no restrictive licenses). I'm searching now, but
just in case my Google searches miss something.....

Thanks,
--jim

[1] Mac Mini 2.7 GHz dual-core i7, 8 GB RAM, 500 GB internal HDD. :-)
Replacing an old, worn-out (literally falling apart) Windoze laptop
(immediately) and maybe an old/tired FreeBSD system (eventually).

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spook...@gmail.com ICBM/Hurr.: 30.44406N 86.59909W

No, I'm not going to explain it. If you can't figure it
out, you didn't want to know anyway... --Larry Wall

Android Apps Listing at http://www.jstrack.org/barcodes.html

Shervin Emami

unread,
Jun 4, 2012, 4:54:34 AM6/4/12
to android-ndk
I was going to recommend OpenCV but you say you had no luck with it.
Was it an install / configuration problem? And if so, did you try
following the 2 official Android tutorials?

Java tutorial: "http://opencv.itseez.com/doc/tutorials/introduction/
android_binary_package/android_binary_package.html"

NDK tutorial: "http://opencv.itseez.com/doc/tutorials/introduction/
android_binary_package/android_binary_package_using_with_NDK.html"

Cheers,
Shervin.

On Jun 3, 10:21 am, Jim Graham <spooky1...@gmail.com> wrote:
> I'm looking for C/C++ image processing references for use with the
> NDK.  I've tried OpenCV, and so far, have had no luck, but I'll be
> getting a new computer[1] in about a week, and will be able to use the
> NDK now, and want to convert all of the Java-based image filters
> to C or C++ using the NDK, which I'm certain will be MUCH faster.
> :-)
>
> Any good links to reference material (online) would be greatly
> appreciated.  Oh, and it needs to be something I can apply in a
> paid app (i.e., no restrictive licenses).  I'm searching now, but
> just in case my Google searches miss something.....
>
> Thanks,
>    --jim
>
> [1] Mac Mini 2.7 GHz dual-core i7, 8 GB RAM, 500 GB internal HDD.  :-)
>     Replacing an old, worn-out (literally falling apart) Windoze laptop
>     (immediately) and maybe an old/tired FreeBSD system (eventually).
>
> --
> THE SCORE:  ME:  2  CANCER:  0
> 73 DE N5IAL (/4)            MiSTie #49997      < Running FreeBSD 7.0 >
> spooky1...@gmail.com                    ICBM/Hurr.: 30.44406N 86.59909W

Jim Graham

unread,
Jun 4, 2012, 6:51:32 AM6/4/12
to android-ndk
On Mon, Jun 04, 2012 at 01:54:34AM -0700, Shervin Emami wrote:
> I was going to recommend OpenCV but you say you had no luck with it.
> Was it an install / configuration problem? And if so, did you try
> following the 2 official Android tutorials?

System limitations currently prevent me from using the NDK (that
problem goes away when my Mac arrives late this week or early next
week---I'm just doing the research part early so I'll be ready to
get back to work on my app when it's here), so I didn't go through
the NDK version of the setup, but the other, yes. I tried to figure out
the conversion from a few samples how to use stuff not in the samples,
and just didn't have any luck. I'll probably try OpenCV again when I CAN
use the NDK, as I can just use the C++ code in the existing non-Android
tutorials without having to change it.

The next question, however, is whether or not that will bloat my app
like a lot of the samples were the last time I checked. Simple C
or C++ code probably wouldn't do that.

Honestly, I'm just looking for simple C or C++ code to do the filters
for my app, such as brightness, contrast, hue, tint, color balance,
sharpen, blur, diffusion, a stronger version of diffusion that covers
only a selected area ... also known as a fog filter, edge enhance, find
contours, and other weird stuff like the last two. I'm also looking
for a C or C++ version of blending two images like the PorterDuff
SR_OVER method in the SDK. Oh, and also converting a byte[] array
to a bitmap (up to the maximum photo size for whatever is the maximum
Android camera resolution for whatever device has the highest), so
the user can then do some post-processing on it, save it as a PNG
(or maybe even TIFF) instead of JPEG, etc.

I've got those in Java, and they work, but some of them are SLOW (even
on my Acer Iconia A500 tablet), and they suffer from Java's limited
memory. I'm hoping to solve both by using native C/C++ for all of
those operations.

I've found some tutorials and libraries in C++ and in C, but they
all either have licenses that prevent use in a paid app (or in an
app, period, for that matter), or they assume that nobody likes
full-color photos (after all, everybody prefers grayscale over
color for ALL photos[1], right?).

Thanks,
--jim

[1] Yes, it is better from an artistic point in SOME photography,
but not always.....

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

"'Wrong' is one of those concepts that depends on witnesses."
--Catbert: Evil Director of Human Resources (Dilbert, 05Nov09)

Shervin Emami

unread,
Jun 5, 2012, 5:18:18 AM6/5/12
to andro...@googlegroups.com
Then you are right, you should just read an image processing book to find how each of those work and then write them all yourself in C/C++ so there will be no bloat at all and no license problems, just your perfect set of functions.
-Shervin

Jim Graham

unread,
Jun 5, 2012, 7:04:25 AM6/5/12
to andro...@googlegroups.com
On Tue, Jun 05, 2012 at 02:18:18AM -0700, Shervin Emami wrote:
> Then you are right, you should just read an image processing book to find
> how each of those work and then write them all yourself in C/C++ so there
> will be no bloat at all and no license problems, just your perfect set of
> functions.

Any suggestions, then? Preferably online/free, but if I have to buy it,
I will (I live on Social Security Disability---VERY limited budget...I'm
CAUTIOUSLY hoping that this app might do well enough to get me out from
under SSD for good).

To begin with, can somebody help me get started with the following:

1) start with a byte[] array from the camera (ARGB_8888) and maybe
a color filter (Android bitmap, also ARGB_8888, may be solid color,
graduated, split-field, or any combination of the above).

2) Re-size the filter bitmap (size of preview) to match the camera
image (which will likely be the largest the camera supports, and
larger than can be handled in Java beyond simply saving to JPEG).

3) Blend the two images using the C/C++ equivalent of PorterDuff
SRC_OVER (basically, the same as using a glass/plastic filter
in front of a 35mm camera lens).

4) Save the result as a PNG.

Oh, and I read somewhere that C++ already has a built-in library that
handles a lot of image processing already, but lost the reference to
that and attempt to Google for it haven't workd, as I don't know
what to search for, specifically, to find it. Does anyone know
A) if that's true, and B) what to search for to find the reference
for it?

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) | Tux (E Cat): DS B+Wd Y 6 Y L+++ W+ C++/C++ I+++
spook...@gmail.com | T++ A E H+ S V- F++ Q+++ P/P+ B++ PA+ PL SC---
< Running FreeBSD 7.0 > |
ICBM / Hurricane: | Tiggerbelle: DS W+S+Bts % 1.5 X L W C+++/C+
30.44406N 86.59909W | I+++ T A E++ H S++ V+++ Q+++ P B++ PA++ PL+ SC

Bakcsi Zsolt

unread,
Jun 5, 2012, 8:16:26 AM6/5/12
to andro...@googlegroups.com, Jim Graham
On Tue, Jun 5, 2012 at 1:04 PM, Jim Graham <spook...@gmail.com> wrote:
> Any suggestions, then?

Just an idea: quite neat things can be done with opengl. I'm not sure
it can do things you've listed, but may be it's worth googling.
For example:
http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions

Another idea: imagemagick is an extensive image manipulation library,
seems like it was ported to Android (didn't try myself):
http://stackoverflow.com/questions/5832217/compile-imagemagick-for-android-using-ndk

Regarding PNG:
http://stackoverflow.com/questions/4573676/saving-as-a-png-image-in-android

Zsolt

Jim Graham

unread,
Jun 5, 2012, 8:26:35 AM6/5/12
to andro...@googlegroups.com
On Tue, Jun 05, 2012 at 02:16:26PM +0200, Bakcsi Zsolt wrote:
> On Tue, Jun 5, 2012 at 1:04 PM, Jim Graham <spook...@gmail.com> wrote:
> > Any suggestions, then?
>
> Just an idea: quite neat things can be done with opengl. I'm not sure
> it can do things you've listed, but may be it's worth googling.
> For example:
> http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions

I know more about doing the image processing in C/C++ already than I
know about OpenGl (for which all I know is its name and that it's a
big graphics display tool for gaming, etc.). Beyond that, well, I
can spell OpenGl. :-)

> Another idea: imagemagick is an extensive image manipulation library,
> seems like it was ported to Android (didn't try myself):
> http://stackoverflow.com/questions/5832217/compile-imagemagick-for-android-using-ndk

Isn't imagemagick GPL? Or is my cancer-nuked memory (cancer #1 again)
doing it to me again? Either way, I'll be checking out the link after
I send this reply and forward this to my tablet (so I don't have to
cut/paste the link from X displayed from my FreeBSD system to the
windoze xp side, start up SeaMonkey (a real system hog on xp), and wait
for it to load). :-)

> Regarding PNG:
> http://stackoverflow.com/questions/4573676/saving-as-a-png-image-in-android

I'll check that, too.

But I would still appreciate any help with the "getting started" stuff
in my previous post.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spook...@gmail.com ICBM/Hurr.: 30.44406N 86.59909W

"The iPad is a status symbol for yuppies. The Android
is for people who actually want something that works."

Jim Graham

unread,
Jun 5, 2012, 11:29:17 AM6/5/12
to andro...@googlegroups.com
On Tue, Jun 05, 2012 at 07:26:35AM -0500, Jim Graham wrote:
> On Tue, Jun 05, 2012 at 02:16:26PM +0200, Bakcsi Zsolt wrote:
> > On Tue, Jun 5, 2012 at 1:04 PM, Jim Graham <spook...@gmail.com> wrote:
> > > Any suggestions, then?
> >
> > Just an idea: quite neat things can be done with opengl. I'm not sure
> > it can do things you've listed, but may be it's worth googling.
> > For example:
> > http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions

I didn't see anything about image processing there. Just display
stuff, GPU, etc..


> > Regarding PNG:
> > http://stackoverflow.com/questions/4573676/saving-as-a-png-image-in-android

Correct me if I'm wrong, but that looks like Java code...more or less
like what I'm using to save PNG files now. As I said, however, doing
this on the Java side runs into the tight (extremely tight) memory
limits which, when working with 5MP and higher Android cameras plus
filter bitmaps, etc., which gets an Out Of Memory exception with the
larger images. That's one key reason for needing to do everything
after the image is captured from C/C++, which I recall being told
does not have those tight memory restrictions.

> But I would still appreciate any help with the "getting started" stuff
> in my previous post.

Still true. :-)

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

"'Wrong' is one of those concepts that depends on witnesses."
--Catbert: Evil Director of Human Resources (Dilbert, 05Nov09)

Jim Graham

unread,
Jun 8, 2012, 12:21:16 AM6/8/12
to andro...@googlegroups.com
Something I don't normally like to do: bump

I'm still hoping someone can point me to some good tutorials, books
or e-books, web sites, etc., for some basic image processing in C
and/or C++. I'm working on getting my new Mac Mini configured now,
and will soon be ready to get started again on the image processing
side of my app. Yes, I will try OpenCV (C++ ONLY) again, but I'd
greatly prefer to stick with matrix (and convolution matrix) stuff.

I'm looking for the following types of stuff (all assuming ARGB_8888
bitmap or byte[] array source):

1) adjust brightness/contrast, gamma, hue, saturation, tint,
negative, grayscale, etc.
2) rotate image
3) round corners (got a neat Java filter for this, but would
prefer ALL filters in C)
4) diffusion
5) blur, Gaussian blur, sharpen, smooth, etc.
6) adjust color levels
7) reflection/mirror
8) edge enhance, emboss, engrave, flip vertical/horizontal, etc
9) some of the more goofy (but still popular) effects like finding
contours (and really doing weird things with them), etc.

Again, any pointers to good reference materials would be greatly
appreciated.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

Do not look into laser with remaining eye.

Fabien R

unread,
Jun 8, 2012, 4:07:03 AM6/8/12
to andro...@googlegroups.com
On 08/06/12 06:21, Jim Graham wrote:
> Again, any pointers to good reference materials would be greatly
> appreciated.
>
> Thanks,
> --jim
>
>
I don't know if it will help but you may ask advices on the GIMP dev
list - or dive in the source code to see how they proceed...
-
Fabien

Reply all
Reply to author
Forward
0 new messages