Login  Register

Re: need help, I'm frustrated

Posted by Hao Jiang-3 on Jul 17, 2008; 10:32pm
URL: http://imagej.273.s1.nabble.com/need-help-I-m-frustrated-tp3695559p3695565.html

Hi Wayne, I've not problem to run your macro, but just can't make it
work in my code.  

public void drawPoints()
{
        if (HDPoints == null)
        {
                return;
        }

        imp = WindowManager.getCurrentImage();
        ImageCanvas ic = imp.getCanvas();
       
        fi = (IntermapFileInfo)imp.getOriginalFileInfo();
        int x, y;
        Calibration cal = imp.getCalibration();
        Rectangle r = imp.getWindow().getCanvas().getSrcRect();

        displayList = new Vector();


        for (int i = 0; i < HDPoints.size(); i++)
        {
                x =
(int)(((HeightSamplePoint)HDPoints.elementAt(i)).getX() /
(fi.decimation));
                y =
(int)(((HeightSamplePoint)HDPoints.elementAt(i)).getY() /
(fi.decimation)) + (int)(cal.yOrigin / fi.decimation);

                if (y >= 0 && y <= fi.height && x >= r.getX() && x <=
r.getX() + r.getWidth())
                {
                        displayList.add(HDPoints.elementAt(i));
                }
        }
       
        int size = displayList.size();

        int[] xPoints = new int[size];
        int[] yPoints = new int[size];

        for(int i=0; i<size; i++){
                HeightSamplePoint point =
(HeightSamplePoint)displayList.elementAt(i);
                xPoints[i]=(int)point.getX();
                yPoints[i]=(int)point.getY();
        }

        Roi roi = new PointRoi(xPoints, yPoints, size);
        IJ.getImage().setRoi(roi);
}

I used log to output points in the 2nd for loop, all there, but just
can't draw them on image

What else I have missed?

Thanks

Hao



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Wayne Rasband
Sent: Thursday, July 17, 2008 12:55 PM
To: [hidden email]
Subject: Re: need help, I'm frustrated


 > Thank you for you reply, I tried this, it worked fine with only few
> points. However, for one test with 20K points, it took almost  >
forever to finish. I believe it's because of "or" operation.

This macro displays 20,000 points as a point selection in just a few
seconds.

   size = 2000;
   count = 20000;
   x = newArray(count);
   y = newArray(count);
   for (i=0; i<count; i++) {
      x[i] = random*size;
      y[i] = random*size;
   }
   newImage("Test", "8-bit Black", size, size, 1);
   run("Point Tool...", "mark=0 selection=yellow");
   makeSelection("point", x, y);

-wayne




*************************************************************************
PRIVILEGE AND CONFIDENTIALITY NOTICE:

The information in this email is intended for the named recipients only.
It may contain privileged and confidential information.  If you have
received this communication in error, any use, copying or dissemination
of its contents is strictly prohibited.  Please erase all copies of the
message along with any included attachments and notify Intermap
Technologies or the sender immediately by telephone at the number
indicated on this page.

*************************************************************************