Action Script in Action Welcome, Guest. Please login or register.
Always stay logged in

Login with username, password and session length
Home Help Search Login Register
Pages: [1]
  Print  
Author Topic: STEREOLOGY PROGRAM/ PICTURE ANALYSER  (Read 166 times)
Janusz
Star
Jr. Member
********

Karma: 0
Offline Offline

Posts: 62


JaNuSz


« on: March 03, 2010, 06:37:40 AM »

STEREOLOGY PROGRAM
Once upon the time I told, that I got a lot of concepts. One is to figure small script program for structure analysis.
I attached sample of the image 2x2um prepared for the analysis - i will write some words about it later. This is metalic glass extracted from "shop alarm blade".
What I need is to find AREA inside the close region. At the first step scale has to be prepared. The best solution may be click on the two points and input the diameter. For instance for this picture it may be click on oposite side and input 0.002mm (2um). Changing the units is not so complicated, so forget about it at this moment.
Fill may be done with function flood fill, which one described here:
http://www.emanueleferonato.com/2008/06/06/flash-flood-fill-implementation/
and here:
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001404.html
For preparation of the MATRIX added script may be used.

About picture preparation: Usually I got 16M color bitmap. It has to be change to B/W so I fill grains with color, which not exist on the picture. After that I mark this color and delete anything else. After that I using "FIND EDGES" function build in many graphical programs. And the result You can see Smiley
So, other script should clear picture from any object which is open or/and has no white pixel inside.

Main Idea is to give swf to all. It let them to make quantitative analysis freely.
As I wrote few days ago, Im too stupid to figure it out. Don't know scripting. What you think Wayne about it? Im not so rich, so maybe as a payment I can make 3d reconstruction of sample You will send me Smiley

Logged
Wayne
Administrator
Full Member
*****

Karma: 0
Offline Offline

Posts: 119


BEER ,beeeeeeeeeeer ah beer.


« Reply #1 on: March 03, 2010, 07:53:10 AM »

Quote
For the above hot link I think this should help you out.

Code:
function flood_fill(x, y)
{
    pos = x + y * 9;
    if (fill_map[y][x] == 0)
    {
        fill_map[y][x] = 2;
        _root["tile_" + (x + y * 9)].gotoAndStop(3);//this tells tile to stop its frame movrment at 3 if changed to 2 you would see black
        flood_fill(x + 1, y);
        flood_fill(x - 1, y);
        flood_fill(x, y + 1);
        flood_fill(x, y - 1);
    }
}
onFrame (1) {
fill_map = new Array();//this is the version of computor programimg that makes up the areas you see
fill_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1];
fill_map[1] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[2] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[3] = [1, 0, 0, 1, 0, 0, 0, 0, 1];
fill_map[4] = [1, 1, 1, 0, 0, 0, 1, 1, 1];
fill_map[5] = [1, 0, 0, 0, 0, 1, 0, 0, 1];
fill_map[6] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[7] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[8] = [1, 1, 1, 1, 1, 1, 1, 1, 1];
for (y = 0; y < 9; y++)
{
    for (x = 0; x < 9; x++)
    {
        tile = _root.attachMovie("tile", "tile_" + (y + x * 9), _root.getNextHighestDepth(), {_x: y * 50, _y: x * 50});
        tile.gotoAndStop(1 + fill_map[x][y]);
    }
}
_root.attachMovie("cursor", "cursor", _root.getNextHighestDepth());
cursor.onEnterFrame = function ()
{
    this._x = 50 * Math.floor(_root._xmouse / 50);
    this._y = 50 * Math.floor(_root._ymouse / 50);
};
_root.onMouseDown = function ()
{
    pos_x = Math.floor(_root._xmouse / 50);
    pos_y = Math.floor(_root._ymouse / 50);
    flood_fill(pos_x, pos_y);
};
}


The next part of the example:

Code:
function flood_fill(x, y)
{
    pos = x + y * 9;
    if (fill_map[y][x] == 0)
    {
        fill_map[y][x] = 2;
        _root["tile_" + (x + y * 9)].gotoAndStop(3);
        flood_fill(x + 1, y);
        flood_fill(x + 1, y + 1);
        flood_fill(x + 1, y - 1);
        flood_fill(x - 1, y);
        flood_fill(x - 1, y + 1);
        flood_fill(x - 1, y - 1);
        flood_fill(x, y + 1);
        flood_fill(x, y - 1);
    }
}
onFrame (1) {
fill_map = new Array();
fill_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1];
fill_map[1] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[2] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[3] = [1, 0, 0, 1, 0, 0, 0, 0, 1];
fill_map[4] = [1, 1, 1, 0, 0, 0, 1, 1, 1];
fill_map[5] = [1, 0, 0, 0, 0, 1, 0, 0, 1];
fill_map[6] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[7] = [1, 0, 0, 0, 1, 0, 0, 0, 1];
fill_map[8] = [1, 1, 1, 1, 1, 1, 1, 1, 1];
for (y = 0; y < 9; y++)
{
    for (x = 0; x < 9; x++)
    {
        tile = _root.attachMovie("tile", "tile_" + (y + x * 9), _root.getNextHighestDepth(), {_x: y * 50, _y: x * 50});
        tile.gotoAndStop(1 + fill_map[x][y]);
    }
}
_root.attachMovie("cursor", "cursor", _root.getNextHighestDepth());
cursor.onEnterFrame = function ()
{
    this._x = 50 * Math.floor(_root._xmouse / 50);
    this._y = 50 * Math.floor(_root._ymouse / 50);
};
_root.onMouseDown = function ()
{
    pos_x = Math.floor(_root._xmouse / 50);
    pos_y = Math.floor(_root._ymouse / 50);
    flood_fill(pos_x, pos_y);
};
}

The main thing to remember is that in 3 you send your movie clips to the libary and link to them to attach to stage. Both examples below.
After this I'll look at you jpgs.


Wayne
Logged
Janusz
Star
Jr. Member
********

Karma: 0
Offline Offline

Posts: 62


JaNuSz


« Reply #2 on: March 03, 2010, 08:10:04 AM »

Thanks, but in fact I have no idea how to use it  Huh?
Other example is here: http://www.monkeybe.com/post/articles/64/index.php
No idea too Sad
Could You add swi file? This script working on VECTORS or on inserted/loaded bitmap too?
Logged
Wayne
Administrator
Full Member
*****

Karma: 0
Offline Offline

Posts: 119


BEER ,beeeeeeeeeeer ah beer.


« Reply #3 on: March 04, 2010, 05:13:33 AM »

OK a quick analysis on the examples. The Flood fill is just that, it will flood in color that is prescript-ed or will send the tile movie clip to a frame where the flood color is.
The two files above demon straights this.
I'm no engineer but I think with time and working together we may come up with something.
I will see if some of what you want to do can be done in Max3 before we need to go to Max4 which I can say will becoming. They are not rushing to give updates like they started to do with Max 3 from Max 2. Plus they have stated they are working on an upgrade to Scripting 3 in the next upgrade.
I'm going on night shift (7PM to 7AM) so I'll not be on as much the next few days. I have a file in mind I want you to look at, I'll see if I can find it before I lay down.

Code:
onFrame (1) {
    img.onRollOver = function(){
        this.useHandCursor = false;
        myFilter = new flash.filters.ColorMatrixFilter ();
        myFilter.matrix = new Array
        (0.333, 0.333, 0.333, 0, 0,
        0.333, 0.333, 0.333, 0, 0,
        0.333, 0.333, 0.333, 0, 0,
        0, 0, 0, 1, 0);
        this.filters = [myFilter];
    }
    img.onRollOut = function(){
        this.filters = [undefined];
    }
}

Well so far didn't find the exact file I want will will find it!!!!!!!!!!!!!!!!!!!!!!!!!!!

See if there is anything here. this is flash 2, 3, 4

Found the one I was looking for zoom with bit maping. As I said see if any of these will start us towards what you are after?  If not give me a starting idea with a file you want to work at.
NaPPPPPPPPPPPPPPPPPPPPPPPP time.

Later

Wayne
« Last Edit: March 04, 2010, 07:59:44 AM by Wayne » Logged
Janusz
Star
Jr. Member
********

Karma: 0
Offline Offline

Posts: 62


JaNuSz


« Reply #4 on: March 04, 2010, 11:10:01 AM »

Giving people free program for picture analysis was my dream since I started using commecials. I just sharing my idea with You. It is not any urgent problem!.
OK, maybe I will give some informations about "how to":
1) the picture has to be BINARY
2) if the picture doesnt meet condition 1 flash may display kind of info or convrt it to b/w
3) two points has to be marked (via mouse clicks) and input box should apear - to input distance between marked points. In this way one can do SCALE
4) Using engine which I add its possible to make na array of all pixels on the picture - using GetPixel function.
5) FloodFill function is for checking if the point in stored array is black or white and make another arrays for all marked regions (grains).
6) if one will have the area of the region inside black pixels it is simple to count something. what one called "equivalent diameter" - d2. d2 is the diameter of the shape - really. d2^2 = Area/Pi - if I remember well. Anyway it is mathematical. If One will have area of all grains and it wil be multiply by SCALE the area will be in nm^2 or um^2 or any SI unit.
7) the last thing is to count how much grains in on the picture and give result: (all grains area) / (quantity of grains). And other usefull is to subtract from all area the sum of grains areas.
It is a lot of scripting. It may take a lot of time. But you are script genius and the term is eternity.
So, I was thinking, that You may think about it if:
- You will have trouble with sleeping;
- You will be alone in home;
- You will be boring.
If I miss something, let me know. I will ask producers of commercial software how they made it.

Janusz
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
DG Style by Fth*