Forum: Ruby image processing

Posted by Nicolò Lazzaro (nicol_l)
on 2012-09-25 03:40
I'm trying to build a program meant to recognize plants by looking at a
picture of their leafs or similar parts.

The approach that I had thought to would be:
- create a mathematical model of the leaves to be recognized
- maybe use some algorithm to combine two pictures from different angles
into one with depth measurement (absolutely don't know how this is done)
- confront the elements of the picture using distance or colors with the
models in the database (basically using only the shape of the borders)

Therefore I am looking for some good and deep guides/sources to teach me
something about this kind of "data modeling", geometrical analysis and
image processing. For now the best that I could find is the Camelia
Library (witch helps a little with colors, but I don't think will be
enough for the shape detection).


I'm aware that this is not a simple project, but I am willing to learn
and spend a good amount of months to get this started
Posted by Eliezer Croitoru (Guest)
on 2012-09-25 04:11
(Received via mailing list)
On 9/25/2012 3:40 AM, Nicol
Posted by Jam Bees (Guest)
on 2012-09-25 06:25
(Received via mailing list)
A crude start could be doing a diff in imagemagick.

Recognizing arbitrary shapes of irregular objects from different angles, 
though, is hard.
Posted by Ralf Mueller (Guest)
on 2012-09-25 09:58
(Received via mailing list)
On 09/25/2012 06:24 AM, Jam Bees wrote:
> A crude start could be doing a diff in imagemagick.
+1

I used it for image processing, like computing vertical and horizontal 
integrals. You can treat images like
pixel arrays, which gives you the possibility to combine them with 
NArray(http://narray.rubyforge.org/) and
the GSL(http://rb-gsl.rubyforge.org/). Imagemagick, NArray and GSL 
should provide a good toolbox for
implementing your analysis.

bw
ralf
Posted by Alexander Blagoev (Guest)
on 2012-09-25 13:17
(Received via mailing list)
I think you could use neural networks too.

http://en.wikipedia.org/wiki/Artificial_neural_network

You can train them, to identify leaves based on their shape, color, etc.

2012/9/25 Ralf Mueller <ralf.mueller@zmaw.de>
Posted by Nicolò Lazzaro (nicol_l)
on 2012-09-25 22:08
Thanks a lot everybody for all your answers and suggestions!
I thought that maybe I could make some use of microsoft kinect or 
similar device to make the 3d map of the object (since getting the data 
from simple photos looks incredibly cpu intensive) using some open 
source elaboration program like PCL ( http://pointclouds.org/ )

Still I'll be extremely interested if anybody could link me some info 
about 3d objects handling in ruby or would simply have some insight to 
share on the argument.

Many thanks,
Nicolò
Posted by Markus Fischer (Guest)
on 2012-09-28 15:47
(Received via mailing list)
On 25.09.2012 13:14, Alexander Blagoev wrote:
> I think you could use neural networks too.
>
> http://en.wikipedia.org/wiki/Artificial_neural_network
>
> You can train them, to identify leaves based on their shape, color, etc.

Coursera.org provides a course starting next week, see details at
https://www.coursera.org/course/neuralnets . It's free and the
introduction video is ... impressive I'd say.

HTH,
- Markus
Posted by Andrew Mcelroy (sophrinix)
on 2012-09-28 16:26
(Received via mailing list)
On Mon, Sep 24, 2012 at 8:40 PM, Nicol L. <lists@ruby-forum.com> wrote:

> I'm trying to build a program meant to recognize plants by looking at a
> picture of their leafs or similar parts.
>

I'm doing this kind of detection with animals.
There is a ruby opencv library, but it doesn't have 100% api coverage 
and
opencv can be a beast in its own right to install.


>
> The approach that I had thought to would be:
> - create a mathematical model of the leaves to be recognized
> - maybe use some algorithm to combine two pictures from different angles
> into one with depth measurement (absolutely don't know how this is done)
> - confront the elements of the picture using distance or colors with the
> models in the database (basically using only the shape of the borders)
>

Stone Age. You will need a lot of samples, but there are a lot of
algorithms you aren't even considering.
You need to look more into Boosting, Bagging, and Stacking algorithms.
For starters look at AdaBoost or WaldBoost algorithm.
Also, check out Bag of Words and SIFT.


>
> Therefore I am looking for some good and deep guides/sources to teach me
> something about this kind of "data modeling", geometrical analysis and
> image processing. For now the best that I could find is the Camelia
> Library (witch helps a little with colors, but I don't think will be
> enough for the shape detection).
>

You need something like opencv.  I think the library you need is
ruby-opencv.
It can be found on github. Follow the instructions for installing opencv
with python first
and build it from source. Also, you are going to want to have fftw 
library
installed.

As for reading material, computer vision/ machine learning for plants 
has a
lot of literature.
Start using scholar.google.com and don't be afraid to ask people at 
other
.edu addresses for advise.

hope this helps.

Andrew McElroy
Posted by Andrew Mcelroy (sophrinix)
on 2012-09-28 16:33
(Received via mailing list)
On Fri, Sep 28, 2012 at 9:25 AM, andrew mcelroy <sophrinix@gmail.com> 
wrote:

> opencv can be a beast in its own right to install.
>
>> image processing. For now the best that I could find is the Camelia
>
> As for reading material, computer vision/ machine learning for plants has
> a lot of literature.
> Start using scholar.google.com and don't be afraid to ask people at other
> .edu addresses for advise.
>
> hope this helps.
>

One more thing, brush up on your calculus, matrix algebra, statistics, 
and
trig.
You want to add the search term "deformable parts" because after all 
plants
leaves are not stiff.
They can twist, bend, fold, etc. You wouldn't want wind screwing up your
detection.
Posted by Miguel Palhas (Guest)
on 2012-10-01 02:39
(Received via mailing list)
What you want to do, particularly the "combine two images from different
angles" is usually called Image Stitching, and there are some standart
methods of doing this

One of the must-know-about API's for this kind of image manipulation is
OpenCV, which is in C/C++. I used it myself last year to do precisely 
Image
Stitching

There is a project on github that wraps it to a ruby gem. The fork with 
the
most recent updates (about 10 days ago) is this one
https://github.com/ruby-opencv/ruby-opencv

However, i've never used it (just learning about it by searching about 
your
question), so i can't tell if it's any good.
But in case it's not usable for your project, you can always code the 
image
processing code in C/C++, and integrate that in your final ruby app
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.