View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001868 | CCdciel | General | public | 17-12-16 21:23 | 18-01-16 17:45 |
Reporter | han | Assigned To | Patrick Chevalley | ||
Priority | none | Severity | feature | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Product Version | 0.9 | ||||
Target Version | 1.0 | ||||
Summary | 0001868: Feature request, a simple CCD inspector | ||||
Description | A feature proposal for consideration. To check the focus in all corners, a simple proposal to display the star HFD values quick and simple. Each star gets a square with dimensions based on the HFD value and textual value. Only about 20 lines code. See attached image. My ASTAP code: procedure Tmainwindow.CCDinspector1Click(Sender: TObject); var fitsX,fitsY,starX,starY,size : integer; begin image1.Canvas.Pen.Mode := pmMerge; image1.Canvas.Pen.width := round(1+height2/image1.height);{thickness lines} image1.Canvas.brush.Style:=bsClear; image1.Canvas.font.color:=clred; mainwindow.image1.Canvas.Pen.Color := $FF; starX:=9999; starY:=9999; for fitsY:=0 to height2-1 do begin for fitsX:=0 to width2-1 do begin if (( (starX-fitsx)*(starX-fitsx) + (starY-fitsY)*(starY-fitsY)>14*14){distance} and (img_loaded[0,fitsX,fitsY]>datamin+0.4*datamax)) then {star} begin HFD(fitsX,fitsY, hfd1,star_fwhm);{star HFD and FWHM} if ((hfd1>0) and (hfd1<99)) then begin size:=round(5*hfd1); image1.Canvas.Rectangle(fitsX-size,height2-fitsy-size, fitsX+size, height2-fitsy+size); image1.Canvas.textout(fitsX,height2-fitsy,floattostrf(hfd1, ffgeneral, 2,1)); starX:=fitsX; starY:=fitsY; end; end; end; end; end; | ||||
Tags | No tags attached. | ||||
|
|
|
Below an improved version. Prevents better double detection and works better with nebula such as M31. I use a similar routine to analyse the images on average HFD. My HFD routine has default an area of 14x14 pixels procedure Tmainwindow.CCDinspector1Click(Sender: TObject); var fitsX,fitsY,size, i, j,imageX,imageY : integer; hfd1,star_fwhm : double; begin image1.Canvas.Pen.Mode := pmMerge; image1.Canvas.Pen.width := round(1+height2/image1.height);{thickness lines} image1.Canvas.brush.Style:=bsClear; image1.Canvas.font.color:=clred; mainwindow.image1.Canvas.Pen.Color := $FF; setlength(img_temp,1,width2,height2);{set length of image array} for fitsY:=0 to height2-1 do for fitsX:=0 to width2-1 do img_temp[0,fitsX,fitsY]:=0;{mark as not surveyed} for fitsY:=0 to height2-1 do begin for fitsX:=0 to width2-1 do begin if (( img_temp[0,fitsX,fitsY]=0){area not surveyed} and (img_loaded[0,fitsX,fitsY]>datamin+0.4*datamax){star}) then {new star} begin HFD(fitsX,fitsY, hfd1,star_fwhm);{star HFD and FWHM} if ((hfd1>0) and (hfd1<99)) then begin size:=round(5*hfd1); if mainwindow.Flipvertical1.Checked=false then imageY:=height2-fitsY else imageY:=fitsY; if mainwindow.Fliphorizontal1.Checked then imageX:=width2-fitsX else imageX:=fitsX; image1.Canvas.Rectangle(imageX-size,imageY-size, imageX+size, imageY+size);{indicate hfd with rectangle} image1.Canvas.textout(imageX,imageY,floattostrf(hfd1, ffgeneral, 2,1));{add hfd as text} for j:=fitsY to fitsY+size do {mark the whole star area as surveyed} for i:=fitsX-size to fitsX+size do if ((j>=0) and (i>=0) and (j<height2) and (i<width2)) then {mark the area of the star square and prevent double detections} img_temp[0,i,j]:=1; end; end; end; end; img_temp:=nil;{free mem} end; |
|
This look like a good option, I try to implement that. |
|
I make an adaption of your code to use in CCDciel. This use the functions in pu_starprofile, including the double star check. I also change the main loop to advance more quickly by a step of half the measurement window. At the end it also print the median hfd of the image. This is started by a new button "Measure image" in the Star profile tool. Please tell me how it work for you. https://sourceforge.net/p/ccdciel/code/754/ https://sourceforge.net/p/ccdciel/code/756/ |
|
Thanks Patrick. I have it running in the compiler and will work on optimization. It is currently too slow. It should look to the bright stars only and I think should show larger rectangles. I will work on the code and come back on this topic. |
|
Han, can you get the last revision 760, I do more change this morning and I just commit a change to make the loop 4 time shorter and add a test for star intensity. The test is at pu_main line 6558: if (vmax>(0.1*fits.HeaderInfo.dmax)) ... You can try to adjust the 0.1 value here. |
|
Patrick, I just read your message 4389. I modified the previous revision as follows: - Added hourglass cursor - Since you move around in larger steps remove img_temp - Added test for vmax See below. Will now compare the versions and take the best :) procedure Tf_main.MeasureImage(Sender: TObject); {measure the median HFD of the image and mark stars with a square proportional to HFD value} var fitsX,fitsY,size,imageX,imageY,s,rs,xxc,yyc,rc,fx,fy,nhfd,overlap : integer; hfd1,star_fwhm : double; vmax,bg,bgdev,xc,yc: double; hfdlist :array of double; Saved_Cursor : TCursor; begin Saved_Cursor := Screen.Cursor; Screen.Cursor := crHourglass; { Show hourglass cursor since analysing will take some time} DrawImage; {draw clean image} imabmp.Canvas.Pen.Mode := pmMerge; imabmp.Canvas.Pen.width := 1;{thickness lines} imabmp.Canvas.brush.Style:=bsClear; imabmp.Canvas.font.color:=clred; imabmp.Canvas.Pen.Color := $FF; s:=14; {test image in boxes of size s*s} overlap:=2; {box overlap} rs:=s-overlap;{ move test box with stepsize rs around} nhfd:=0; SetLength(hfdlist,nhfd); for fy:=3 to ((img_Height) div rs)-3 do begin fitsY:=fy*rs; for fx:=3 to ((img_Width) div rs)-3 do begin fitsX:=fx*rs; hfd1:=-1; f_starprofile.FindStarPos(fits.image,fits.imageC,fits.imageMin,fitsX,fitsY,s,fits.HeaderInfo.naxis1,fits.HeaderInfo.naxis2,xxc,yyc,rc,vmax,bg,bgdev); if ((vmax>fits.imagemax*0.1) {new bright star found} and (xxc>=fitsX-round(s/2)+overlap) and (yyc>=fitsY-round(s/2)+overlap) {prevent double detections in overlap area} and (not f_starprofile.double_star(fits.image,fits.imageC,fits.imageMin,rc, xxc,yyc)) ) {ignore double stars} then f_starprofile.GetHFD(fits.image,fits.imageC,fits.imageMin,xxc,yyc,rc,bg,bgdev,xc,yc,hfd1,star_fwhm,vmax);{calculated HFD} if ((hfd1>0.8) and (hfd1<99)) then begin inc(nhfd); SetLength(hfdlist,nhfd); hfdlist[nhfd-1]:=hfd1; {store hfd list} size:=round(5*hfd1);{show a square 10 times larger the HFD for quick HFD evaluation in all corners} imageY:=round(yc); imageX:=round(xc); imabmp.Canvas.Rectangle(imageX-size,imageY-size, imageX+size, imageY+size);{indicate hfd with rectangle} imabmp.Canvas.textout(imageX+size,imageY+size,floattostrf(hfd1, ffgeneral, 2,1));{add hfd as text} end; end; end; if nhfd>0 then NewMessage('Image median hfd='+formatfloat(f1,SMedian(hfdList)){+ ' out of '+inttostr(nhfd)+' detections'}); SetLength(hfdlist,0); PlotImage; Screen.Cursor := saved_cursor; end; |
|
I had a look to the last revision 760. I think adjustment of the box of 14 is not required. Ideally a focused star should have cover a square area 2 or 3 pixels. So a detection box 14x14 should be fine. I used fits.imagemax rather then fits.HeaderInfo.dmax. No idea if it makes any difference. In the code below I moved the fixed overlap of 2 to the FindStarPos. This will make it a little faster. Without this overlap some stars will be missed. I added in the reporting the number of detections. Probably better to remove it. The square boxes I made large, 2*5*HFD . My idea is to give the user a quick visual overview if stars in all corners are of equal size. For me I can see quickly see a wrong mounting alignment of the camera. The text is moved to right bottom corner of the squares. Img_temp is not required since the box is moved in steps of s=14 around and there should practical no overlap. Added a crHourglass cursor. For me this is fine. I'm happy with the tool. procedure Tf_main.MeasureImage(Sender: TObject); {measure the median HFD of the image and mark stars with a square proportional to HFD value} var fitsX,fitsY,size,imageX,imageY,s,xxc,yyc,rc,fx,fy,nhfd : integer; hfd1,star_fwhm : double; vmax,bg,bgdev,xc,yc: double; hfdlist :array of double; Saved_Cursor : TCursor; const overlap=2; {box overlap,results in 1 pixel overlap} begin Saved_Cursor := Screen.Cursor; Screen.Cursor := crHourglass; { Show hourglass cursor since analysing will take some time} DrawImage; {draw clean image} imabmp.Canvas.Pen.Mode := pmMerge; imabmp.Canvas.Pen.width := 1;{thickness lines} imabmp.Canvas.brush.Style:=bsClear; imabmp.Canvas.font.color:=clred; imabmp.Canvas.Pen.Color := $FF; s:=14; {test image in boxes of size s*s} nhfd:=0; SetLength(hfdlist,nhfd); for fy:=3 to ((img_Height) div s)-3 do { move test box with stepsize rs around} begin fitsY:=fy*s; for fx:=3 to ((img_Width) div s)-3 do begin fitsX:=fx*s; hfd1:=-1; f_starprofile.FindStarPos(fits.image,fits.imageC,fits.imageMin,fitsX,fitsY,s+overlap,fits.HeaderInfo.naxis1,fits.HeaderInfo.naxis2,xxc,yyc,rc,vmax,bg,bgdev); if ((vmax>fits.imagemax*0.1) {new bright star found} and (xxc>fitsX- round(s/2)) and (yyc>fitsY-round(s/2)) {prevent double detections in overlap area} and (not f_starprofile.double_star(fits.image,fits.imageC,fits.imageMin,rc, xxc,yyc)) ) {ignore double stars} then f_starprofile.GetHFD(fits.image,fits.imageC,fits.imageMin,xxc,yyc,rc,bg,bgdev,xc,yc,hfd1,star_fwhm,vmax);{calculated HFD} if ((hfd1>0.8) and (hfd1<99)) then begin inc(nhfd); SetLength(hfdlist,nhfd); hfdlist[nhfd-1]:=hfd1; {store hfd list} size:=round(5*hfd1);{show a square 10 times larger the HFD for quick HFD evaluation in all corners} imageY:=round(yc); imageX:=round(xc); imabmp.Canvas.Rectangle(imageX-size,imageY-size, imageX+size, imageY+size);{indicate hfd with red square} imabmp.Canvas.textout(imageX+size,imageY+size,floattostrf(hfd1, ffgeneral, 2,1));{add hfd as text} end; end; end; if nhfd>0 then NewMessage('Image median hfd='+formatfloat(f1,SMedian(hfdList))+ ' out of '+inttostr(nhfd)+' detections'); SetLength(hfdlist,0); PlotImage; Screen.Cursor := saved_cursor; end; |
|
I like your last version and it work fine. This is committed in revision 762. I only add a test to check there is a valid image before to start the procedure and add a message if no star is found. In rev 763 I change the button text to "Image inspection" and add a hint to clarify what it do. fits.imagemax is the same as dmax, no problem. The bigger box was a test to see if this procedure can do something useful with a defocused image. But I am not convinced by the result and I don't think it can help for autofocus, I get too much bogus hfd for stars at the limit of the detection threshold. |
Date Modified | Username | Field | Change |
---|---|---|---|
17-12-16 21:23 | han | New Issue | |
17-12-16 21:23 | han | File Added: M52, CCD inspection.png | |
17-12-18 16:44 | han | File Added: m31 ccd inspection.png | |
17-12-18 16:44 | han | Note Added: 0004363 | |
17-12-18 17:07 | han | Note Edited: 0004363 | |
17-12-18 23:25 | Patrick Chevalley | Assigned To | => Patrick Chevalley |
17-12-18 23:25 | Patrick Chevalley | Status | new => assigned |
17-12-18 23:25 | Patrick Chevalley | Target Version | => 1.0 |
17-12-18 23:25 | Patrick Chevalley | Note Added: 0004365 | |
18-01-15 19:31 | Patrick Chevalley | Status | assigned => feedback |
18-01-15 19:31 | Patrick Chevalley | Note Added: 0004386 | |
18-01-16 11:04 | han | Note Added: 0004388 | |
18-01-16 11:04 | han | Status | feedback => assigned |
18-01-16 11:51 | Patrick Chevalley | Note Added: 0004389 | |
18-01-16 13:44 | han | Note Added: 0004390 | |
18-01-16 15:09 | han | Note Added: 0004391 | |
18-01-16 15:15 | han | Note Edited: 0004391 | |
18-01-16 17:45 | Patrick Chevalley | Status | assigned => resolved |
18-01-16 17:45 | Patrick Chevalley | Resolution | open => fixed |
18-01-16 17:45 | Patrick Chevalley | Note Added: 0004392 |