Author Topic: AnnotateImage fails on large images  (Read 2447 times)

Offline robhawleyastro

  • Newcomer
  • Posts: 34
AnnotateImage fails on large images
« on: 2016 October 26 10:36:23 »
I am trying to annotate an extremely large image (31+ degrees). 

Code: [Select]
run --execute-mode=auto "/Applications/PixInsight/src/scripts/AdP/AnnotateImage.js"

Processing script file: /Applications/PixInsight/src/scripts/AdP/AnnotateImage.js
Referentiation Matrix (Gnomonic projection = Matrix * Coords[x,y]):
           -0.000969673        +7.81254e-13            +15.9996
           +7.76651e-11        -0.000969672            +10.1816
                     +0                  +0                  +1
Projection origin.. [16500.001697 10500.001974]pix -> [RA:+23 15 22.00 Dec:+62 15 00.99]
Resolution ........ 3.491 arcsec/pix
Rotation .......... 0.000 deg
Focal ............. 531.79 mm
Pixel size ........ 9.00 um
Field of view ..... 31d 59' 57.1" x 20d 21' 47.2"
Image center ...... RA: 23 15 21.999  Dec: +62 15 01.00
Image bounds:
   top-left ....... RA: 26 04 01.540  Dec: +66 44 18.65
   top-right ...... RA: 20 26 42.457  Dec: +66 44 18.66
   bottom-left .... RA: 24 51 57.408  Dec: +49 36 24.23
   bottom-right ... RA: 21 38 46.590  Dec: +49 36 24.24

Downloading Vizier data:
http://vizier.cfa.harvard.edu/viz-bin/asu-tsv?-source=V/50/catalog&-c=348.841664 62.250277&-c.r=21.976989&-c.u=deg&-out.form=|&-out.add=_RAJ,_DEJ&-out=pmRA&-out=pmDE&-out=Name&-out=HR&-out=HD&-out=DM&-out=SAO&-out=Vmag&-out=B-V&-out=U-B&-out=R-I&-out=SpType&Vmag=<8
49843 bytes transferred in 0.56 s @ 87.13 KB/s
fov:21.976989 actual:21.971583
Catalog Bright Stars  size: 194 objects inside the image


Catalog NamedStars size: 63 of 3672 objects

Catalog Messier size: 1 of 110 objects

Catalog NGC-IC size: 56 of 9933 objects

Removing duplicate objects:
     [i].. snip ..[/i]
Found 58 duplicate objects in 0.08 s
Rendering annotation
Error: VectorGraphics.end(): the graphics context is not active


I can reproduce this problem on both Windows 10 and MacOS Sierra.

Offline robhawleyastro

  • Newcomer
  • Posts: 34
Re: AnnotateImage fails on large images
« Reply #1 on: 2016 October 26 11:09:35 »
One problem that I found after I posted this. Look at the reported top left and bottom left RA's. 

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AnnotateImage fails on large images
« Reply #2 on: 2016 October 26 11:14:23 »
I need the image to be able to find where is the problem.

Offline robhawleyastro

  • Newcomer
  • Posts: 34
Re: AnnotateImage fails on large images
« Reply #3 on: 2016 October 27 18:09:04 »
OK the file that was failing can be found here
http://robhawley.net/ToPixi/

Syn_BrightStars.xisf was created using CatalogStarGenerator and is intended to help get the correct distortion in the main image.  I was going to use this as a reference for operational mosaic

ImageSolver was able to finish on the first version of the operational mosaic.  Annotate ran successfully on the operational mosaic. The distortion did not complete so some of the annotation is off.  I was going to post these as well, but even compressed they are multi gByte images. Thus I decided to wait until I hear whether you actually need them.

I reconfirmed this afternoon that Annotate fails on Syn_BrightStars.xisf.

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AnnotateImage fails on large images
« Reply #4 on: 2016 October 28 11:14:58 »
AnnotateImage uses an object named VectorGraphics from the PJSR library. This object seems to be limited to images of less than 2GB. Since the annotation bitmaps use 4 bytes per pixel the script can not annotate images bigger than 536,870,912 pixels.

I will add a message warning of this.

Thanks for helping me to improve the script.

Andrés

Offline robhawleyastro

  • Newcomer
  • Posts: 34
Re: AnnotateImage fails on large images
« Reply #5 on: 2016 October 28 17:33:22 »
except (at least on a Mac) it was able to annotate a the operational image which is nearly 4 Gbytes.  Syn_BrightStars is only 2 GB.  All are single channel images.

Perhaps I am hitting a different limit.  Syn_BrightStars is 33000 x 21000  The operation image that worked is 31127x16982.

Tomorrow I am going to generate a synthetic image the exact size of the operational image and see if that works.

Offline robhawleyastro

  • Newcomer
  • Posts: 34
Re: AnnotateImage fails on large images
« Reply #6 on: 2016 October 28 23:03:09 »
OK I reduced the size of the synthetic image to the same size as the operational mosaic  (31127 x 16982).  That worked

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: AnnotateImage fails on large images
« Reply #7 on: 2016 October 28 23:58:01 »
The Graphics and VectorGraphics JavaScript objects, as well as the pcl::Graphics and pcl::VectorGraphics C++ classes, use Qt's QPainter as their back end for low-level painting. As any raster-based painting system, QPainter has limitations:

http://doc.qt.io/qt-5/qpainter.html#limitations

So it cannot paint outside the [-32767,+32767] range of coordinates in both plane directions. Note that this restriction only applies to the visible viewport, not to the range of usable coordinates, which is the range of 32-bit signed integers. For example, you can draw a line from -100000,-100000 to +100000,+100000 without problems, as long as the intersection with the visible viewport, or visible clipping region, does not exceed [-32767,+32767].

So one solution would be splitting the drawing into several sub-regions smaller than 32767 x 32767 and painting the whole drawing in successive steps, with each sub-region enabled as a clipping region with the VectorGraphics.clipRect property (or with template member function pcl::VectorGraphics::SetClipRect()). Should work :)

Edit: Of course, Bitmaps also have size limitations, which in some cases (Windows?) may be OS-dependent. For example, on Linux I cannot create a bitmap with more than 2^29 pixels, or larger than 23170 x 23170 pixels. This seems obvious since a bitmap pixel requires 4 bytes. Again, this limitation could be overcome to paint on a larger image by splitting the drawing into sub-regions.
« Last Edit: 2016 October 29 00:12:30 by Juan Conejero »
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AnnotateImage fails on large images
« Reply #8 on: 2016 October 29 03:19:35 »
Hi Juan, I have a pending pull request with several changes including one about this problem.