1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| public void track (ImagePlus imp, int x, int y, int frame) {
// Number of frames in the movie
int max = imp.getStackSize ();
frame ++;
if (frame == max + 1){
return; // if the movie is finished
}
// select the current slice
imp.setSlice (frame);
// associate current slice with processor
ImageProcessor processor = imp.getProcessor();
// research of the value of the pixel (x,y)
int pixels = processor.getPixel(x,y);
// if the grayscale is the same => no change, the molecule didn't move
if (pixels == 0) {
IJ.write ( " " + frame + " \t " + x + " \t " + y + " \t No change");
track (imp,x,y,frame);
return ;
// else it researchs the new position of the molecule
} else {
int min = 150;
int xmin = 0, ymin = 0;
for (int ys = y - 10; ys <= y + 10; ys ++) {
for (int xs = x; xs >= 0; xs--) {
// research of the value of the pixel (xs,ys)
pixels = processor.getPixel(xs,ys);
// I eliminate the trajectories superior to 150 pixels
if ((pixels == 0) && (x - xs < min)) {
min = x - xs;
xmin = xs;
ymin = ys;
}
}
}
if (min != 150) {
IJ.write ( " " + frame + " \t " + xmin + " \t " + ymin + " \t Movement of the molecule");
track (imp,xmin,ymin,frame);
return;
} else { IJ.write ( " " + frame + " \t " + x + " \t " + y + " \t No change");
track (imp,x,y,frame);
return;
}
}
} |
Partager