Message Boards Message Boards

0
|
10335 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to repeat an image processing routine?

Attachments:
2 Replies

David, thank you so much for your help. It works perfectly.

However, after having this routine working I perceived that images .fits guide to results slightly erratic. Modifying the parameters for images .tiff format the problem disappears completely. It seems that opening images .fits occurs some loss of information. Could you explain this type of problem ???

Best, Antonio

Posted 9 years ago

Hi Antonio,

Here is one method. I took your code as written and combined your calculations for a single radius value into a function that accepts r and produces the calculation. Then this is used in a Table expression to produce a list of data pairs. I suggest reading up on function definitions and Module. Also note that rather than the range expression Table would also accept a list of values for radius.

This is for me a common methodology. I develop a single calculation, cell by cell, and then Merge the cells into a single cell defining a function. Then use Table or Map to evaluate the function repeatedly for a range or list of data items or values. I attach a revised notebook.

Best, David

(* Build a function to determine encircled energy from r *)
encircledEnergy[r_] := Module[
  {disk, dat, list},
  disk = ColorConvert[
    ColorNegate@
     Graphics[{Black, Disk[ct, r]}, ImageSize -> {w, h}, 
      PlotRange -> {{0, 1000}, {0, 1000}}], "Grayscale"]; 
  dat = disk // ImageData; list = Position[dat, 1.]; 
  Apply[Plus, Extract[i // ImageData, list]] 
  ]

(* now build a table of values *)
results = 
  Table[{radius, encircledEnergy[radius]}, {radius, 0, 500, 25}];

ListLinePlot[results, PlotMarkers -> {Automatic, 10}, 
 PlotLabel -> "Encircled Energy", PlotTheme -> "Scientific", 
 FrameLabel -> {"Radius", "Sum of Intensities"}, ImageSize -> 500, 
 LabelStyle -> 16]

enter image description here

Attachments:
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract