From a18c2ed05ffd833c82720af0cc250e881a979c73 Mon Sep 17 00:00:00 2001 From: Eric Mandel Date: Thu, 16 May 2019 15:45:38 -0400 Subject: [PATCH] fix bugs in imexam plugins using a rotated line to defined the image section --- js9-allinone.js | 9 +++++--- js9.js | 1 + js9.min.js | 2 +- js9plugins.js | 7 ++++-- plugins/imexam/imexam.html | 47 ++++++++++++++++++-------------------- plugins/imexam/imexam.js | 7 ++++-- 6 files changed, 40 insertions(+), 33 deletions(-) diff --git a/js9-allinone.js b/js9-allinone.js index 93f20bc9..780eb51a 100644 --- a/js9-allinone.js +++ b/js9-allinone.js @@ -2786,7 +2786,7 @@ RAWID0:"raw0",RAWIDX:"alt",IDFMT:" (%s)",MINZOOM:.125,MAXZOOM:32,ADDZOOM:.1,CHR a.BROWSER=function(){var a=navigator.platform,c=navigator.appName,d=navigator.userAgent,e,f=d.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);e=d.match(/version\/([\.\d]+)/i);f&&null!==e&&(f[2]=e[1]);f=f?[f[1],f[2],a]:[c,navigator.appVersion,"-?",a];f.push(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(d));return f}();a.PIXEL_RATIO=function(){var a=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio|| a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1)}();a.globalOpts={helperType:"none",helperPort:2718,requireHelper:!1,allinoneHelper:!1,requireFits2Fits:!1,quietReturn:!1,useWasm:!0,allowFileWasm:!1,winType:"light",rgb:{active:!1,rim:null,gim:null,bim:null},defcolor:"#00FF00",pngisfits:!0,fits2fits:"never",fits2png:!1,prependJS9Dir:!0,dataDir:null,alerts:!0,valposTarget:null,valposWidth:"medium",internalValPos:!0,internalContrastBias:!0,containContrastBias:!1,wcsCrosshair:!1, regionsToClipboard:!0,magnifierRegions:!0,pannerDirections:!0,htimeout:1E4,lhtimeout:1E4,ehtimeout:5E3,ehretries:10,xtimeout:18E4,extlist:"EVENTS STDEVT",imopts:"IMOPTS",imcmap:"IMCMAP",table:{xdim:4096,ydim:4096,bin:1},image:{xdim:4096,ydim:4096,bin:1},reproj:{xdim:4096,ydim:4096},reprojSwitches:"",binMode:"s",clearImageMemory:"heap",helperProtocol:location.protocol,reloadRefresh:!1,reloadRefreshReg:!0,panWithinDisplay:!1,svgBorder:!0,unremoveReg:100,maxMemory:75E7,corsURL:"params/loadcors.html", -proxyURL:"params/loadproxy.html",loadProxy:!1,imsectionURL:"params/imsection.html",postMessage:!1,waitType:"spinner",spinColor:"#FF0000",spinOpacity:.35,resize:!0,resizeHandle:!0,resizeRedisplay:!0,cloneNewDisplay:!0,logoDisplay:!1,lightWinClose:"ask",regionDisplay:"lightwin",regionConfigSize:"medium",refreshDragDrop:!0,reduceMosaic:"js9",reduceRegcnts:!0,plot3d:{cube:"*:*:all",mode:"avg",areaunits:"pixels",color:"green"},copyWcsPosFormat:"$ra $dec $sys",floatPrecision:6,mouseActions:["display value/position", +proxyURL:"params/loadproxy.html",loadProxy:!1,imsectionURL:"params/imsection.html",postMessage:!1,waitType:"spinner",spinColor:"#FF0000",spinOpacity:.35,resize:!0,resizeHandle:!0,resizeRedisplay:!0,cloneNewDisplay:!0,logoDisplay:!1,lightWinClose:"ask",regionDisplay:"lightwin",regionConfigSize:"medium",refreshDragDrop:!0,reduceMosaic:"js9",reduceRegcnts:!0,plot3d:{cube:"*:*:all",mode:"avg",areaunits:"pixels",color:"green"},imexamLineHeight:1,copyWcsPosFormat:"$ra $dec $sys",floatPrecision:6,mouseActions:["display value/position", "change contrast/bias","pan the image"],touchActions:["display value/position","change contrast/bias","pan the image"],keyboardActions:{b:"toggle selected region: source/background",c:"toggle crosshair",d:"send selected region to back",e:"toggle selected region: include/exclude","M-e":"edit selected region",i:"refresh image",I:"display full image","M-i":"display selected cutouts","M-k":"toggle keyboard actions plugin",l:"toggle active shape layers","M-l":"new JS9 light window","M-m":"toggle mouse/touch plugin", "M-o":"open local file",P:"paste regions from local clipboard",p:"paste regions to current position",u:"undo remove of region(s)","M-,":"toggle preferences plugin","M-p":"toggle preferences plugin",r:"copy selected region to clipboard",R:"copy all regions to clipboard",s:"select region",S:"select all regions","M-s":"toggle shape layers plugin","/":"copy wcs position to clipboard","?":"copy value and position to clipboard",0:"reset zoom","=":"zoom in","+":"zoom in","-":"zoom out","^":"raise region layer to top", ">":"display next image","<":"display previous image","delete":"remove selected region",leftArrow:"move region/position left",upArrow:"move region/position up",rightArrow:"move region/position right",downArrow:"move region/position down"},mousetouchZoom:!1,toolbarTooltips:!1,centerDivs:["JS9Menubar"],resizeDivs:["JS9Menubar","JS9Colorbar","JS9Toolbar"],pinchWait:8,pinchThresh:6,xeqPlugins:!0,extendedPlugins:!0,intensivePlugins:!1,dynamicSelect:"click",dynamicHighlight:!0,corsProxy:"https://js9.si.edu/cgi-bin/CORS-proxy.cgi", @@ -15979,7 +15979,10 @@ function reg2section(xreg) { (xreg.pts[0].x - xreg.pts[1].x)) + ((xreg.pts[0].y - xreg.pts[1].y) * (xreg.pts[0].y - xreg.pts[1].y))); - xreg.height = 1; + xreg.height = JS9.globalOpts.imexamLineHeight || 1; + xreg.angle = Math.atan2(xreg.pts[1].y - xreg.pts[0].y, + xreg.pts[1].x - xreg.pts[0].x); + xreg.angle = xreg.angle * 180 / Math.PI; } else { xreg.width = maxx - minx; xreg.height = maxy - miny; @@ -16004,7 +16007,7 @@ exports.getRegionData = function (im, xreg) { var imag; if ( xreg.angle && xreg.angle !== 0 ) { - imag = ndops.zeros([xreg.width, xreg.height]); + imag = ndops.zeros([xreg.height, xreg.width]); ndops.rotate(imag, im_2d, xreg.angle/57.29577951, xreg.y, xreg.x); } else { diff --git a/js9.js b/js9.js index 4b23c6df..835bec8e 100644 --- a/js9.js +++ b/js9.js @@ -172,6 +172,7 @@ JS9.globalOpts = { reduceMosaic: "js9", // "js9" or "shrink" ("js9" seems to be faster) reduceRegcnts: true, // reduce image when doing counts in regions? plot3d: {cube:"*:*:all", mode:"avg", areaunits:"pixels", color: "green"}, // plot3d options: avg/sum, pixels/arcsecs + imexamLineHeight: 1, // "height" of line region section copyWcsPosFormat: "$ra $dec $sys", // format for copy wcs pos to clipboard floatPrecision: 6, // precision for floatToString() mouseActions: ["display value/position", "change contrast/bias", "pan the image"],// 0,1,2 mousepress diff --git a/js9.min.js b/js9.min.js index 87bbe904..3877f355 100644 --- a/js9.min.js +++ b/js9.min.js @@ -11,7 +11,7 @@ RAWID0:"raw0",RAWIDX:"alt",IDFMT:" (%s)",MINZOOM:.125,MAXZOOM:32,ADDZOOM:.1,CHR a.BROWSER=function(){var a=navigator.platform,c=navigator.appName,d=navigator.userAgent,e,f=d.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);e=d.match(/version\/([\.\d]+)/i);f&&null!==e&&(f[2]=e[1]);f=f?[f[1],f[2],a]:[c,navigator.appVersion,"-?",a];f.push(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(d));return f}();a.PIXEL_RATIO=function(){var a=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio|| a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1)}();a.globalOpts={helperType:"none",helperPort:2718,requireHelper:!1,allinoneHelper:!1,requireFits2Fits:!1,quietReturn:!1,useWasm:!0,allowFileWasm:!1,winType:"light",rgb:{active:!1,rim:null,gim:null,bim:null},defcolor:"#00FF00",pngisfits:!0,fits2fits:"never",fits2png:!1,prependJS9Dir:!0,dataDir:null,alerts:!0,valposTarget:null,valposWidth:"medium",internalValPos:!0,internalContrastBias:!0,containContrastBias:!1,wcsCrosshair:!1, regionsToClipboard:!0,magnifierRegions:!0,pannerDirections:!0,htimeout:1E4,lhtimeout:1E4,ehtimeout:5E3,ehretries:10,xtimeout:18E4,extlist:"EVENTS STDEVT",imopts:"IMOPTS",imcmap:"IMCMAP",table:{xdim:4096,ydim:4096,bin:1},image:{xdim:4096,ydim:4096,bin:1},reproj:{xdim:4096,ydim:4096},reprojSwitches:"",binMode:"s",clearImageMemory:"heap",helperProtocol:location.protocol,reloadRefresh:!1,reloadRefreshReg:!0,panWithinDisplay:!1,svgBorder:!0,unremoveReg:100,maxMemory:75E7,corsURL:"params/loadcors.html", -proxyURL:"params/loadproxy.html",loadProxy:!1,imsectionURL:"params/imsection.html",postMessage:!1,waitType:"spinner",spinColor:"#FF0000",spinOpacity:.35,resize:!0,resizeHandle:!0,resizeRedisplay:!0,cloneNewDisplay:!0,logoDisplay:!1,lightWinClose:"ask",regionDisplay:"lightwin",regionConfigSize:"medium",refreshDragDrop:!0,reduceMosaic:"js9",reduceRegcnts:!0,plot3d:{cube:"*:*:all",mode:"avg",areaunits:"pixels",color:"green"},copyWcsPosFormat:"$ra $dec $sys",floatPrecision:6,mouseActions:["display value/position", +proxyURL:"params/loadproxy.html",loadProxy:!1,imsectionURL:"params/imsection.html",postMessage:!1,waitType:"spinner",spinColor:"#FF0000",spinOpacity:.35,resize:!0,resizeHandle:!0,resizeRedisplay:!0,cloneNewDisplay:!0,logoDisplay:!1,lightWinClose:"ask",regionDisplay:"lightwin",regionConfigSize:"medium",refreshDragDrop:!0,reduceMosaic:"js9",reduceRegcnts:!0,plot3d:{cube:"*:*:all",mode:"avg",areaunits:"pixels",color:"green"},imexamLineHeight:1,copyWcsPosFormat:"$ra $dec $sys",floatPrecision:6,mouseActions:["display value/position", "change contrast/bias","pan the image"],touchActions:["display value/position","change contrast/bias","pan the image"],keyboardActions:{b:"toggle selected region: source/background",c:"toggle crosshair",d:"send selected region to back",e:"toggle selected region: include/exclude","M-e":"edit selected region",i:"refresh image",I:"display full image","M-i":"display selected cutouts","M-k":"toggle keyboard actions plugin",l:"toggle active shape layers","M-l":"new JS9 light window","M-m":"toggle mouse/touch plugin", "M-o":"open local file",P:"paste regions from local clipboard",p:"paste regions to current position",u:"undo remove of region(s)","M-,":"toggle preferences plugin","M-p":"toggle preferences plugin",r:"copy selected region to clipboard",R:"copy all regions to clipboard",s:"select region",S:"select all regions","M-s":"toggle shape layers plugin","/":"copy wcs position to clipboard","?":"copy value and position to clipboard",0:"reset zoom","=":"zoom in","+":"zoom in","-":"zoom out","^":"raise region layer to top", ">":"display next image","<":"display previous image","delete":"remove selected region",leftArrow:"move region/position left",upArrow:"move region/position up",rightArrow:"move region/position right",downArrow:"move region/position down"},mousetouchZoom:!1,toolbarTooltips:!1,centerDivs:["JS9Menubar"],resizeDivs:["JS9Menubar","JS9Colorbar","JS9Toolbar"],pinchWait:8,pinchThresh:6,xeqPlugins:!0,extendedPlugins:!0,intensivePlugins:!1,dynamicSelect:"click",dynamicHighlight:!0,corsProxy:"https://js9.si.edu/cgi-bin/CORS-proxy.cgi", diff --git a/js9plugins.js b/js9plugins.js index 6673d802..95b3bf62 100644 --- a/js9plugins.js +++ b/js9plugins.js @@ -12502,7 +12502,10 @@ function reg2section(xreg) { (xreg.pts[0].x - xreg.pts[1].x)) + ((xreg.pts[0].y - xreg.pts[1].y) * (xreg.pts[0].y - xreg.pts[1].y))); - xreg.height = 1; + xreg.height = JS9.globalOpts.imexamLineHeight || 1; + xreg.angle = Math.atan2(xreg.pts[1].y - xreg.pts[0].y, + xreg.pts[1].x - xreg.pts[0].x); + xreg.angle = xreg.angle * 180 / Math.PI; } else { xreg.width = maxx - minx; xreg.height = maxy - miny; @@ -12527,7 +12530,7 @@ exports.getRegionData = function (im, xreg) { var imag; if ( xreg.angle && xreg.angle !== 0 ) { - imag = ndops.zeros([xreg.width, xreg.height]); + imag = ndops.zeros([xreg.height, xreg.width]); ndops.rotate(imag, im_2d, xreg.angle/57.29577951, xreg.y, xreg.x); } else { diff --git a/plugins/imexam/imexam.html b/plugins/imexam/imexam.html index cd696d7c..65744fda 100644 --- a/plugins/imexam/imexam.html +++ b/plugins/imexam/imexam.html @@ -10,17 +10,21 @@
-

- -

Region Statistics

+

JS9 Imexam Plugins

-A rectangular box of image pixels is selected and some statistical values -are computed from the data. The selected box may be rotated for box and -ellipse regions. +These tasks perform various types of image analysis using a rectangular box +surrounding the selected region. That is, the actual region shape is ignored +and the analysis reflects a rectangular section of image pixels. The selected +section can be rotated for box, ellipse, and line regions. For a line region, +the width is the length of the line, while the height is set to the value of +the JS9.globalOpts.imexamLineHeight parameter (default is 1).

-N.B.: Currently the region shape is ignored and the values reflect a rectangular section of image pixels. -

+ +

Region Statistics

+ +A rectangular box of image pixels is selected and some statistical +values are computed from the data.

Notes

@@ -54,21 +58,18 @@

Notes

X and Y Projection Plot

-A rectangular box of image pixels is selected and the projection along the -region's X or Y axis is plotted. The sum, average or median of the projected -pixels may be selected. The selected box may be rotated for box and ellipse -regions. - +A rectangular box of image pixels is selected and the projection along +the region's X (width) or Y (height) axis is plotted. The sum, +average, or median of the projected pixels may be selected.

Radial Profile

-A rectangular box of image pixels is selected and the pixels values are -plotted against their respective radii. A Gaussian is fit to the radial profile -data and the result is also plotted. The fitted results of the 4 parameter fit -are displayed with the plot. The selected box may be rotated for box and -ellipse regions. +A rectangular box of image pixels is selected and the pixels values +are plotted against their respective radii. A Gaussian is fit to the +radial profile data and the result is also plotted. The fitted +results of the 4 parameter fit are displayed with the plot.

The center pixel from which the radii are computed is determined from the @@ -80,12 +81,9 @@

Radial Profile

Pixel Value Histogram

-A rectangular box of image pixels is selected and a histogram of the values -is plotted. The selected box may be rotated for box and -ellipse regions. - -The selected pixels are binned into 250 bins between the minimum and maximum value -found in the selected region. +A rectangular box of image pixels is selected and a histogram of the +values is plotted. The selected pixels are binned into 250 bins +between the minimum and maximum value found in the selected region.

@@ -122,7 +120,6 @@

Encircled Energy

3d Surface Plot

A rectangular box of image pixels is selected and plotted as a surface. -The selected box may be rotated for box and ellipse regions.
diff --git a/plugins/imexam/imexam.js b/plugins/imexam/imexam.js index 150a45b9..6a100631 100644 --- a/plugins/imexam/imexam.js +++ b/plugins/imexam/imexam.js @@ -557,7 +557,10 @@ function reg2section(xreg) { (xreg.pts[0].x - xreg.pts[1].x)) + ((xreg.pts[0].y - xreg.pts[1].y) * (xreg.pts[0].y - xreg.pts[1].y))); - xreg.height = 1; + xreg.height = JS9.globalOpts.imexamLineHeight || 1; + xreg.angle = Math.atan2(xreg.pts[1].y - xreg.pts[0].y, + xreg.pts[1].x - xreg.pts[0].x); + xreg.angle = xreg.angle * 180 / Math.PI; } else { xreg.width = maxx - minx; xreg.height = maxy - miny; @@ -582,7 +585,7 @@ exports.getRegionData = function (im, xreg) { var imag; if ( xreg.angle && xreg.angle !== 0 ) { - imag = ndops.zeros([xreg.width, xreg.height]); + imag = ndops.zeros([xreg.height, xreg.width]); ndops.rotate(imag, im_2d, xreg.angle/57.29577951, xreg.y, xreg.x); } else {