Jump to content

  •  

CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.

Photo

how to make all images the same size in PI

  • Please log in to reply
33 replies to this topic

#1 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 12:50 AM

I realized I can't use Blink or other tools unless all my images are the same size.

 

Now let's say I have many images that are a different size. I created a Dynamic Crop, did it on one image, specifying 0,0 as the anchor point and 200x200 as the crop size, then dragged the process to a little icon on the background, then went to Image container, loaded all the images I want that crop and applied the image container instance to the icon I dragged earlier. TLDR: this basically applies the same crop to all my images. 

 

When I looked at my images, they all seem to be a slightly different size after the crop. If my crop target was say 200x200, the result was like 200x202, 198x204

 

super annoying to see it off like 2 pixels...why does that happen?


Edited by joelin, 03 December 2019 - 12:51 AM.


#2 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:07 AM

Try StarAlignment.

Francesco



#3 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:07 AM

These are solar images with partial disk so I don’t SA will work.

#4 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:10 AM

FFTRegistration then?



#5 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:18 AM

Tried that and it failed. I need to crop the images so I can feed them into a 3rd party registration software that requires them all to be the same dimsenion



#6 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:21 AM

Can you post the source code for your DynamicCrop instance?



#7 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:31 AM

var P = new DynamicCrop;
P.centerX = 0.50000;
P.centerY = 0.50000;
P.width = 1.00000;
P.height = 1.00000;
P.angle = 0.0000;
P.scaleX = 1.00000;
P.scaleY = 1.00000;
P.optimizeFast = true;
P.interpolation = DynamicCrop.prototype.Auto;
P.clampingThreshold = 0.30;
P.smoothness = 1.50;
P.xResolution = 72.000;
P.yResolution = 72.000;
P.metric = false;
P.forceResolution = false;
P.red = 0.000000;
P.green = 0.000000;
P.blue = 0.000000;
P.alpha = 1.000000;
P.noGUIMessages = false;

 

 

Pm963pw.png


Edited by joelin, 03 December 2019 - 01:32 AM.


#8 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:39 AM

As you can see, the size in pixels is not part of the source. Width and height are expressed in terms of ratio to the original size...



#9 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:43 AM

ah that makes sense...so basically it is not possible to do what im proposing using the dynamic crop tool even though it seems like it should support that capability... 

 

thanks for the info

 

so i would have to do it one at a time manually then?



#10 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:45 AM

Can you consider first resampling to a specified pixel size, and then using a relative crop? In this way all the output images would have the same pixel size.



#11 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:51 AM

all my images were captured at the same pixel scale...they started off as videos that autostakkert then determined the intersection of all usable frames in the video to stack and output...each video had varying amounts of error in the tracking/guiding so thats why the outputs from autostakkert aren't all the same 

 

not sure what you mean by resampling to a specified pixel size



#12 fmeschia

fmeschia

    Apollo

  • *****
  • Posts: 1,103
  • Joined: 20 May 2016
  • Loc: Mountain View, CA

Posted 03 December 2019 - 01:54 AM

I see. Then probably the only practical way would be to prepare a program to crop all image files outside of PI. There are Python libraries that can handle FITS files pretty well.



#13 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 02:18 AM

I spent time searching Lightroom and Photoshop and it seems they can only do a batch resize to new dimensions or batch relative crop ....



#14 2ghouls

2ghouls

    Viking 1

  • *****
  • Posts: 857
  • Joined: 19 Sep 2016

Posted 03 December 2019 - 08:27 AM

2 ideas:

1. Have you tried using the regular “crop” process in PI, not “DynamicCrop”?

2. It is possible to batch crop to exact dimensions with photoshop. Just record yourself using the crop tool and in the preset drop down choose the WxHxRes. option. Type in your values: for example: 200, 200, 72. Apply a crop from the upper left corner on one image. Stop recording. Apply your recorded action to a folder of images with the File->Automate->Batch... option.

#15 Alex McConahay

Alex McConahay

    Cosmos

  • *****
  • Posts: 8,357
  • Joined: 11 Aug 2008
  • Loc: Moreno Valley, CA

Posted 03 December 2019 - 09:13 AM

>>>>> I need to crop the images so I can feed them into a 3rd party registration software that requires them all to be the same dimsenion

 

Have you tried feeding the original images to that registration software?

 

What is the name of that software?

 

On a different path: Are you saying the original subs were not the same size?

I don't understand.  If you were taking them from the same camera, would then not all be the same size? 

 

Alex


Edited by Alex McConahay, 03 December 2019 - 09:14 AM.


#16 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:01 PM

2 ideas:

1. Have you tried using the regular “crop” process in PI, not “DynamicCrop”?

2. It is possible to batch crop to exact dimensions with photoshop. Just record yourself using the crop tool and in the preset drop down choose the WxHxRes. option. Type in your values: for example: 200, 200, 72. Apply a crop from the upper left corner on one image. Stop recording. Apply your recorded action to a folder of images with the File->Automate->Batch... option.

1. I tried both. It seems from Francesco's observation, that they both operate as a relative crop (a % of the total) rather than an absolute crop in pixels

2. Interesting, I'll look into that. Any good tutorials for recording yourself. 



#17 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 01:06 PM

>>>>> I need to crop the images so I can feed them into a 3rd party registration software that requires them all to be the same dimsenion

 

Have you tried feeding the original images to that registration software?

 

What is the name of that software?

 

On a different path: Are you saying the original subs were not the same size?

I don't understand.  If you were taking them from the same camera, would then not all be the same size? 

 

Alex

1) Yes, it fails unless the image are the same dimension and 4000 px maximum on the longest edge

2) Keith's Image Stacker

3) Yes

4) I took 100+ videos and they were all the same dimension. I then sent them all through Autostakkert which takes each video, finds the best frames, finds the intersection of those frames and creates one output. This was for capturing the Mercury Transit and because of imperfect tracking/guiding, the intersection of best frames in each video was slightly different and hence the output has different dimensions



#18 Alex McConahay

Alex McConahay

    Cosmos

  • *****
  • Posts: 8,357
  • Joined: 11 Aug 2008
  • Loc: Moreno Valley, CA

Posted 03 December 2019 - 01:41 PM

OK....sounds like you did everything one would expect, and it did what it should. But what it should do was not usable as such. I'll think about it, but nothing has come to mind. 

Alex



#19 joelin

joelin

    Vanguard

  • *****
  • topic starter
  • Posts: 2,140
  • Joined: 14 Jan 2008
  • Loc: Saratoga, CA

Posted 03 December 2019 - 02:17 PM

I rather surprised PI's crop doesn't replicate itself the way I expect it to using the triangle.

 

Think about it...if I enter crop width, height and anchor point all in pixels (not as a % of the total) and create a process out of it...why does it think I want a % of total when the original specification was in pixels?

 

 

typically people use identical sized subs and do a crop out of them...which the pixel count would work perfectly.... the only reason i can think of them wanting to use the % is if people typically want to crop different sized subs in the same aspect ratios but different final dimension... 

 

i dont know what the use case for that is

 

but then again my situation with the mercury transit isnt a common use case either


Edited by joelin, 03 December 2019 - 02:18 PM.


#20 Jon Rista

Jon Rista

    ISS

  • *****
  • Posts: 23,859
  • Joined: 10 Jan 2014
  • Loc: Colorado

Posted 03 December 2019 - 03:49 PM

Have you tried DynamicAlignment? This is what I use to align multi-frame and multi-panel images of the moon. You identify notable features in two images and it will align the source to the target.



#21 giorgio_ne

giorgio_ne

    Vostok 1

  • -----
  • Posts: 139
  • Joined: 22 Apr 2010
  • Loc: London, England

Posted 03 December 2019 - 05:37 PM

Not sure if it works for solar images but RegiStar could be the one trick pony for this job:

https://aurigaimaging.com



#22 gatsbyiv

gatsbyiv

    Viking 1

  • *****
  • Posts: 694
  • Joined: 29 Mar 2009
  • Loc: Doylestown, PA

Posted 03 December 2019 - 08:05 PM

I read this thread and thought, "no way, they must be missing some setting."  Then I went and tried it myself.  Unbelievable.  I can almost see DynamicCrop not working this way, but the Crop process allows you to enter the exact pixels you want.  It even has a setting called "absolute margin in pixels" that should do exactly what you ask.  It doesn't.  That has to be a bug.

 

Of course, when you click the documentation button to see an explanation, you get nothing.  Because... PixInsight.


  • Astrola72 likes this

#23 pfile

pfile

    Fly Me to the Moon

  • -----
  • Posts: 5,296
  • Joined: 14 Jun 2009

Posted 03 December 2019 - 09:06 PM

i think you can do this with pixelmath. i just got pulled away from the computer, but here's a very non-paramaterized setting that will copy the square area starting at the top left corner from an image and put it into a new image which is 2536x2536 in size. the inrect() call can be modified to push it over and down. i could probably parametize this to be more friendly... anyway from here probably you can figure it out...

 

rob

 

Screen Shot 2019-12-03 at 6.03.33 PM.png


Edited by pfile, 03 December 2019 - 09:07 PM.


#24 pfile

pfile

    Fly Me to the Moon

  • -----
  • Posts: 5,296
  • Joined: 14 Jun 2009

Posted 03 December 2019 - 09:14 PM

well, i might have to play with that more, not sure you need inrect(), i think the pixel location is relative to the image being created. never really run pixelmath with a differing output image size so it will take a little fiddling.

 

rob



#25 pfile

pfile

    Fly Me to the Moon

  • -----
  • Posts: 5,296
  • Joined: 14 Jun 2009

Posted 03 December 2019 - 10:14 PM

ok here we go... this will copy the center of an image to a new image which is size pixels square. it could be made more elegant if there is a way for pixelmath to know the size of the output image. not sure if that function exists.

 

as it stands, you need to set the output image size to the same dimensions as whatever you assign to size. the expression editor contains this code (you can't see it in the screenshot)

 

size=1000;
toprightX = (width($T)/2)-size/2;
toprightY = (height($T)/2)-size/2;
pixel($T,x()+toprightX,y()+toprightY)

 

 

the center point of the square being copied is controlled by the (width($T)/2) and (height($T)/2) - half the image in both dimensions is the center of the target image. you could conceivably change this to whatever you want. i just figured your image would be roughly centered on the center of each frame.

 

 

Screen Shot 2019-12-03 at 7.06.26 PM.png

 

having said all this, maybe you don't actually need to crop anything. i was just showing this since we're all talking about the Crop process. but maybe all you want to do is this:

 

pixel($T,x(),y())

 

and just set the output size to be larger than your largest image. i think if you use ImageContainer on that you'll get a bunch of images with the original images crammed into the top left corner of the image, with the rest black. if your stacking program is going to re-register then it won't matter where the sun is though.

 

rob

 




CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.


Recent Topics






Cloudy Nights LLC
Cloudy Nights Sponsor: Astronomics