Tuesday, May 31, 2011

ANN Works for any file in the right format.

Any file passed to the ANN can be processed in the right format.

Currently the ANN just trains on the file given, then tests on the same file.

XOR works:


Ratio of Area and Perimeter.

Monday, May 30, 2011

ANN (Works only for the testing file I used?)

Cleaned up the testing data to be much more simplified, and now the ANN won't use it. The format of the file is entirely identical, and everything gets set up correctly but it won't run the learner.

Did up some graphs to see distribution







Friday, May 27, 2011

ANN Updated

I gave the program now able to parse the text files and set up the appropriate (array of arrays).

Lots of problems with the text parsing, and the array of arrays. Had no idea how difficult an array of arrays would be vs 2D arrays.

Had trouble with blank lines in the text files (the program still does not like those) or lines with tabs and spaces but no data.

Will have to make sure to have the ANN sent only lines with data on it (No Species)

It gets stuck with an epoch of 16,479.5-- Always, so I'm not sure why this is, or what the difference is.

Thursday, May 26, 2011

C# + ANN

ANN still only does XOR; but now it succeeds at classifying XOR every time, before it would get stuck with an epoch of .25 ~ .6

The ANN itself now actually allows you to change the number of hidden nodes, before it was a set number for the XOR function.

The main program now allows a user to specify a species to a blob, and identify it as being that species. When measurements (soon to be written to a space separated text file) are performed it gives the species name as well.

Small presentation this morning  the readings required were read.

There are still some things about the functionality for the ANN in AForge. I don't fully understand, their tutorials on the ANN class aren't really that helpful for it. I don't know how it will react to such a large data set.

Text file format for ANN is as follows:

Training File---
#Of-Columns #Of-Classes(Species) #Lines
Data
Data
.
.
.

Testing File--- (Actual data that needs to be classified)
#Lines
Data
.
.


I don't know how well ANN will do at classifying, or if it even can (I was thinking only classifying genera (?))

The perimeter may be solvable by taking the area of the "outline" (it appears to be a constant width line) so might be able to divide by some factor instead of dealing with the jumbled up blob points list.

Tuesday, May 24, 2011

ANN, and "Diatom Segmenter"

One bug left to worry about in updating the map with the current bitmap. the current bitmap should change every time it's changed but doesn't appear to.

Program can now let you overlay/blend two images together, but will revert back to the old image when you try to make an alteration (splitting/deletion)

You can now connect two blobs together via the "blob splitter" by using right click instead of left click. just fill in the hole(s).

ANN is started, simple ANN built; using AForges Machine Learning, and Neuro classes. ANN is just an XOR Classifier, where you can adjust the weights of momentum, and learning rate.

GUI using WFA allows all these controls.

It appears (right now) that the classification may have to be put in itself, by the number the program returns. 1.0 = species A, 2.0 = species B, etc.

Thursday, May 19, 2011

Program

Undo added [with button] max of 15 steps back.

Program uses a lot more memory now, especially when the undo list is filled (800 Mb)
Once you perform 15 undos in a row the size drops down to the regular 150-300 Mb

Now have the option to view each step by itself.

Have an overlay option for any step with any other step by some percentage (very slow - doesn't seem to work quite right).

Get blob points gives me a list of all the edge points of a blob. But in no order that makes sense, or makes it easy to measure or even outline the blob. Working on figuring out a way to sort this list.

Tuesday, May 17, 2011

Program Continued

Console now has colors in its output.

Delete button and graphic for it added.
Can delete single blobs (a few bugs here with deleting incorrect blobs) (Center of Gravity)

A blob inside a blob may get deleted by accident.

The program now performs the area measurement (still isn't being correctly modified to microns)

Small other chunks changed, more comments.

Program doesn't appear to have the memory leak anymore but still uses 300 megs of memory when it peaks.

Monday, May 16, 2011

C#

Program now runs much faster for the same results.

You can now decide how you wish for a selected blob to be displayed:

As shown currently (filled in)
Outline only
Original (The original image)

The toolbar buttons have an actual image associated with them.

Code is better commented.


Console outputs useful information about what the program is currently doing.

Thursday, May 12, 2011

More implementation in C#

More has been added to the C# program.

You can now slice apart junk and diatoms. If you slice up junk into small chunks it gets removed.

The objects now get filled in fully, and if you view them with the blob selector it provides an outline of the blob.

Still a few unknown bugs, and the program seems to sometimes crash due to out of memory errors. So I may have a memory leak(?). I try disposing everything I can. But sometimes that causes more errors (Argument Exception) I still get (less often) that a "Generic error occurred in the GDI+"

Wednesday, May 11, 2011

C# + Reading

More work has been completed these past 2 days in c#. The program is coming along nicely. Lots of buggy sections right now but a lot has been fixed. The program now allows the user to click a blob (correctly) and display it larger. This is where a user will split the junk off/circle the diatom (if required).

You can now select to squares to set the value for the binarization.

Will be working on a "Delete" (Stroke - for now a button) that when the user signals that a certain hitbox is full of only junk it is removed from the current set. (Not sure on how to remove a specific blob from the current bitmap at this time)

A current bug is with the clicking to view one blob, if there are any overlapping blobs (by hitbox) no matter where you click, all overlapping segments recursively get put into one large hitbox (or so it seems) these all come up to be viewed larger instead of the one you clicked on. Not sure why this would happen.


Finished reading the Falko-Raven Chapter 1, quite a bit confusing. Maybe tomorrow will help clarify a little more.

Read both papers:
http://plankt.oxfordjournals.org/content/18/3/393.short
http://plankt.oxfordjournals.org/content/25/6/669.short

Seems like this may be useful in a bit, to look at some alterations to the C# program to better segment the image.

Monday, May 9, 2011

C#

Started a better more full application in C#. Does nearly everything the old application does and a little bit more, still some bug fixes to be done. Program is up in the repository.

Program allows the user to select a blob to look at it more closely (this is where the user can split these blobs into more than one blob if need be).

This program doesn't yet perform the measurements.

Friday, May 6, 2011

After finding a C# .NET Library for Image Processing (and more) last night. I had decided to try it out.

.NET Library and source - http://www.aforgenet.com/framework/
Image Processing Lab built with the library - http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx

It was very quick and easy to convert between bitmap and save files in C#. Quick example of flow of the test program made.


GUI once opened

Open Image - Normal File Dialog

Binarize by threshold

Filter blobs less than a desired size.


Detect the blobs by color.

Label the blobs' bounding box and show the area the blob has imposed on the original image.

Thursday, May 5, 2011

Measurements Made + JMF and Marvins Framework

Method        -    AREA    PERIM        FERET    F-X    F-Y    F-THETA    MIN-FERET

Python        -   233.129    65.752        19.683    87.820    1.765    93.857    17.166

Java Plugin -    217.050    78.701        20.173    79.545    10.591    163.151    16.680

ImageJ      -    336.494    104.861        30.466    70.278    8.605    162.943    21.498

Actual      -     282.742    60.301        20.122    86.055    23.610    78.936    18.275


The method of using Python seems to be very close to the actual on this particular image.

Python Method -

Convert the image in python to a binary image with a threshold of 128.
Open image into ImageJ and convert to Binary (ImageJ requires inverted colors)
Fill Holes.
Dilate and Erode (for this particular image 3 times each).

There are a few areas where things can vary if you change the numbers (threshold, and dilate and erode). But Python works well (slide-000)

Python was not always the best for other slides, but the less complicated slides (with very little to no junk surrounding the diatom) appear to work best with Python.

Java Media Framework(JMF) and Marvins Framework, don't appear to be useful for this. They have no more tools for use than ImageJ Libraries supply.

Images showing the diatom that was measured for slide-000.


ImageJ

Python

Original

Java Plugin

Wednesday, May 4, 2011

Programming

Finished reading the tutorial documentation for python. Finally found a 64bit version of JIL for python 2.6.

Ran through some of the documentation for that, and got a little ways.

It appears Python is very useful for images, quick short commands to change what you need. I don't know how well anything else will work in python when it comes to trying to measure the images' segmented objects; if it can even segment the objects.

Original Image



Image converted to grayscale, and then converted to binary with a threshold of 128.

im = Image.open("image.tif").convert("L").point(lambda i: i >= 128 and 255 or 0)

Another way of converting to binary/gray scale. Image didn't go all white and black.

im = Image.open("image.tif").convert("1").point(lambda i: i >= 128 and 255 or 0)
Image remained RGB, did the threshold of 128.
im = Image.open("image.tif").point(lambda i: i >= 128 and 255 or 0)


I tried working with JMF, and "Marvin's Framework"

http://marvinproject.sourceforge.net/en/index.html

There is a lot of documentation; it could be useful, will look at getting this set up to use and test.

Built a plugin usable for ImageJ; The plugin doesn't do much other than converting the image to grayscale, finding the edges, and converting that to binary with a threshold of 128.



Java built ImageJ Plugin function ran. See code.


Seems like it's an easy to use utility, documentation is well written for ImageJ.

        IJ ij = new IJ();
        Image i = ij.getImage().getImage();
       
        BufferedImage buffImage = new BufferedImage(i.getWidth(null),i.getHeight(null),BufferedImage.TYPE_BYTE_GRAY);
        Graphics g = buffImage.getGraphics();
        g.drawImage(i,0,0,null);
        g.dispose();
        Image im = buffImage;
        ij.getImage().setImage(im);
       
        ImageProcessor IP = ij.getImage().getProcessor();
        IP.findEdges();
        ByteProcessor BP = (ByteProcessor) IP.convertToByte(false);
        BP.threshold(128);
        ij.getImage().repaintWindow();

ImageJ Harder Image

Here is a run through with the harder image in order. All the junk becomes selected in one large block. Maybe some more can be done at a different step to pull it into smaller chunks.

Original Image

Background added

Image converted to binary.

  
Overlay of the two images

Tuesday, May 3, 2011

Python

Started learning the more advanced stuff in Python to be ready and jump into Python Imaging Library(PIL) to see what can be done with that in means of image segmentation. Just ran through python documentation chapters 1 through 8. Set up Python to work in Eclipse IDE and worked on doing modules (which I had never done).

Used to the syntax now, seems like there may be some usefulness to it. Simplistic data structures that can be used to hold all the images.

More ImageJ

After reading the chapter on binary images in the text book, and trying a few more things in ImageJ I found a process where "adding" a background worked nicely.


Original Image

Image with background added.


Image converted to binary.

Overlay of original and binary image.

Monday, May 2, 2011

ImageJ

I have found a way to build new plugins for ImageJ; I don't know how well this will work with using other Java features at the same time though.

Using a little bit in ImageJ I found that doing certain processes in order does have a positive effect on possibly grabbing at some of the diatoms.

 
Original Image
Image with background removed (Process in ImageJ).
Image with background removed, converted to binary.

Image with find edges process, converted to binary, with holes filled in.
Image with background removed, converted to binary, and holes filled in.




The images still select a lot of garbage, but they select the diatoms as well.

By performing a Gaussian blur and then reconverting to binary you get much more defined blobs.