0

I have a question about input to neural network!

I want to recognize one kind of leaf.

I have 3000 images with different sizes and angles. I am using emgucv and visual studio 2010 c#.

First I convert all my training data to grayscale then I transform grayscale images to binary images. But to recognize leaves I decided to use some method based on shapes.

Is it a good idea??

Johana
  • 61
  • 1
  • 9

2 Answers2

1

The ideal is to have an input data in a form of a matrix, either an RGB, greyscale or B&W matrix, each of the 3000 images should be converted to this data format. just don't worry about the shape, ie: a leave outer perimeter is just a series of continuous local differences between Color A and Color B ( the Hidden layers handle this).

Can you be more specific on why you chose your method ? Try to see this thread about preparing images for training the NN. You can also check Neuroph for java as an example to have an idea how images are prepared on a RGB basis and a shape basis.

Community
  • 1
  • 1
  • Ohh yap.!I read the link that you gave!And the easy way is !!Convert all images in grayscale and then convert in binary images and each pixel will be an input to ann is that right? . My images has 640x480 Should I resized to 20x20? – Johana Feb 28 '14 at 04:16
  • And is there a way to convert 3000 images at onces? because it a waste of time to convert one by one! – Johana Feb 28 '14 at 04:19
  • The smaller the images, the better is the result on a NN, it's always recommended to Scale image dimensions used for training to the same test dimensions to avoid possible issues. Use the same color mode and image dimensions for training and recognition. If color is not important for you use black and white since training is faster. – Zougou Lougou Feb 28 '14 at 11:56
  • And for the conversion, what are you using for your "one by one" if it's a piece of code try batch processing the images with it. This thread provides how to [resize images in c#](http://stackoverflow.com/questions/1922040/resize-an-image-c-sharp) and this one is very helpful for you on [converting color image into black and white and then to a binary file](http://social.msdn.microsoft.com/Forums/vstudio/en-US/6d4d4518-8b9e-413d-aaf7-eac953291c3c/convert-color-image-into-black-and-white?forum=csharpgeneral). just insert the code in a big _for loop_ :) – Zougou Lougou Feb 28 '14 at 12:19
  • ooohh!!For examples I have a images that contains a leaf and a background!But leaf don't occupy all image so in that case I must crop images in order leaf occupy all images Am I correct!! – Johana Feb 28 '14 at 18:53
  • The cropping isn't obligatory, and no ! it is not better to train the NN with different angles (like 0° and 180°) but angles like (+-30°) are good enough to train your NN for variety. – Zougou Lougou Feb 28 '14 at 22:29
  • hey.If I use images of apples in order to be recognized by ANN , so if images contain 2 or more apple ANN tell that images contain apples?? or onnly recognize one object inside images – Johana Apr 04 '14 at 21:52
1

I used neural network with EMGU for handwriting digit recognition, maybe it can help you.

It is a supervised classification problem, so you need to define 3 things (they will impact the quality of the recognition) : 1. Classes, 2. Examples, 3. Features.

  1. You have to define classes (in my case I had 10 classes : "1", "2", "3", ..., "9", "0"). In your case you can have 2 classes ("the kind of leaves you want to recognize" VS "the others leaves") or N classes ("the kind of leaves you want to recognize" VS "another kind" VS "another kind"...)

  2. Then you need examples for each class, for learning. In my case I used 10 000 images per class.

  3. Finally you need to extract features. Usually I use shape (Zernike or Hu moments), color (color moment) and texture (Tamura, Gabor...). You can also use directly the pixel values of your image as an input. Normalizing the size and orientation of your image (or the content of the image) could be a good idea if your features are not robust to rotation and scale.

Olivier A
  • 842
  • 4
  • 8
  • First I will use pixel values like an input.!I have define 2 clases, that is a leaf that I want to recgonize and that is not a leaf(I give a image that contains a leaf and NN must tell me "That is a leaf" and if I give images that contains a rock NN must tell "that is not a leaf")!what do you mean when you said normalizing orientation? Is not it better train NN with different images with different angles?? – Johana Feb 28 '14 at 18:56
  • If the object you want to recognize can have different orientations, you have 3 solutions : 1. learn several images with several orientations, 2. extracting features robust to rotation (such as SIFT, Hu, etc) or 3. "normalize" the orientation with preprocessing, i.e. process your image in order to be sure that learning and training image have same orientation. – Olivier A Mar 01 '14 at 00:11
  • mmm I decided to use the first solution!Can you explain me one question more? Well I told before I use each pixel of images as input to ANN fo example If I have 2 images with 10x10. Input should be 10x10=100 x 2 images = 200. In this case I have 200 inputs is that right? – Johana Mar 01 '14 at 03:31
  • No, the NN recognize one image at a time. If you want to recognize two images, you should use the NN two times. If you image has 10x10 pixel your input has 100 features/dimensions. You should check [EMGU example NN](http://www.emgu.com/wiki/index.php/ANN_MLP_%28Neural_Network%29_in_CSharp) – Olivier A Mar 03 '14 at 09:03
  • mmm For example if ANN recognize a pen How can I draw a rectangle in place where pen is?? – Johana Mar 22 '14 at 20:00
  • With classification techniques such as NN, SVM, etc. you can't. It is just classification, not object retrieval. – Olivier A Mar 23 '14 at 10:48
  • ok I understand. Another question. I read about input format of ANN. I saw that They convert images to graysacle and then normalize values in order to get values between 0-1. Is there a problem if I do not normalize values and give ANN values between 0-255(because images are in grayscale)? – Johana Mar 23 '14 at 17:26
  • Yes I think it is ok, you should try. – Olivier A Mar 24 '14 at 19:37
  • hey, Do I nedd to crop images in oder to leave only object than I want to recognize? or Can I use original images without crop(Each image only contain object that I can to recognize) ? – Johana Mar 24 '14 at 20:21
  • Becacuse I do not understand. I train my ANN with image of pens that I cropped and background like non pens.but when I input a image of pen with some background, ANN tell me that image is a non pen but when I crop image and leave only image of pen ,ANN tell me that is a pen and I do not why? – Johana Mar 25 '14 at 00:15
  • It is simple, ANN recognize only what it learn. If you learn croped pen it will recognize croped pen. You were talking about leaf and know about pen... I don't understand. ANN is not magical. You should open a new discussion and ask specific question. – Olivier A Mar 25 '14 at 07:48
  • hey.If I use images of apples in order to be recognized by ANN or SVM, so if images contain 2 or more apple ANN or SVM tell that images contain apples?? or onnly recognize one object inside images – Johana Apr 04 '14 at 21:51