Cutting large images into tiles

Moderator: jsachs

Post Reply
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Cutting large images into tiles

Post by MarkT »

After playing with a large image (25200 x 19800) for a few days, I have tried to split the image into smaller tiles to make printing a little easier. I ended up using crop, but the placement of the crop selection rectangle was a little too manual for high precision.

I was doing this for a friend, as otherwise I would have used the Horizontal and Vertical tile operations in the Print dialogue to send the image fragments directly to my printer.

So, I'm wondering if there is a way to modify the tiling operation in Print to send to files, instead of to a printer? Or modify Crop to allow for the same tiling functionality? Basically, some way to easily split an image into parts, and save each part as an image file?
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Cutting large images into tiles

Post by jsachs »

The attached workspace file will, when run, ask for the name of an image file, load it, and split it into 4 equal parts.

You can do a precise crop by entering in the margins as numbers instead of dragging the crop rectangle manually.
Attachments
Split 4.zip
(858 Bytes) Downloaded 132 times
Jonathan Sachs
Digital Light & Color
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Re: Cutting large images into tiles

Post by MarkT »

Oh, of course - enter the crop margins as numbers... it was staring right at me!

Thank you. And thanks for the neat workspace script. One question: in Branch 2 the margins include "Right = -202". Is there some reason for taking the margins outside of the image area in this one crop?

And this means I could build my own workspace scripts ( for 9 crops, etc...). Very clever, thank you.
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Cutting large images into tiles

Post by jsachs »

No, sorry I missed that. The attached workspace file should work.
Attachments
Split 4.zip
(856 Bytes) Downloaded 115 times
Jonathan Sachs
Digital Light & Color
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Re: Cutting large images into tiles

Post by MarkT »

Perhaps you can help me with the manual entry of crop margins...

I'm attempting to break a 25200 x 19800 pixel image into 9 segments. Each segment should be 8400 x 6600 pixels.

I have a workspace open similar to the "Split 4" example you sent, only I have 9 branches open.

I use Crop with Custom Proportions: 84 and 66, and Resize is off.

Starting in the lower left, then across and up in a zig-zag pattern, The first 5 segments work perfectly. But then I'm having trouble getting the margins to do want I want them to do - they keep "autocorrecting" to numbers just slightly off from what I enter. For example, here is the matrix of values, and the the results I get after manually entering the coordinates: (Every value set should be a variation of 0, 6600, 8400, 13200 and 16800)

Left Right Top Bottom
0 16800 13200 0
8400 8400 13200 0
16800 0 13200 0
0 16800 6600 6600
8400 8422 6603 6615 X
16970 0 6591 6600 X
16800 0 0 13200
8345 8455 0 13200 X
0 16800 0 13200

As I try to enter the value I want, the other margin values change. (It's like a game of whack-a-mole...)

I'm missing something, but I can't put my finger on it. Any suggestions would be greatly appreciated.

Thanks

Mark
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Cutting large images into tiles

Post by jsachs »

Turn off custom proportions - when applied to another image, the cropping is always relative to the image size. You can enter the margins as 0, w/3, 2*w/3, 0, h/3, 2*h/3 where w is the image width and h is the image height. You can enter the margins as an expression.

Another trick is to edit the numbers in the workspace file (which is a text file) using Notepad. The crop box is specified as a center and a width and height (cx, cy, w, h) normalized to a range of 0.0 .. 1.0. So the lower left sub-rectangle is centered at 1/6, 1/6 and width and height are both 1/3. For example, this is from Split4.workspace:

image index 2 caption ″Crop″ comment ″″ saved_as ″″ saved_on ″″ parent 4 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴crop 0 nx 1492 ny 994 cx 0.25 cy 0.25 w 0.5 h 0.5 angle 0 proportions 0 orientation 0 units 0 batch_reset_crop_rect 0 grid 0 n 3 grid_name ″None″ propwidth 1 propheight 0.66621984 resize 0 resample 0 resamplesize 8 resampledimension 0 resampleunits 1 resampledpi 300 resamplemethod 2 display 2 auto_preview 1‴
end_image
Jonathan Sachs
Digital Light & Color
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Re: Cutting large images into tiles

Post by MarkT »

Perfect - Using "Arbitrary" did the trick, I am able to enter the margin values with no issues.

Adding Export transformations, and running as a Batch worked perfectly. Thank you so much for the help. Took only 30-40 seconds to crop and save all nine images.

As far as editing the .workspace file, that may take me longer to wrap my head around, but looks like a very slick way to update this for images with different requirements.

Again, thank you very much!
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Re: Cutting large images into tiles

Post by MarkT »

So, one more question, and please pardon my ignorance with what is probably very basic mathematics...

In your example you say the margins could be entered as an "expression", and list 6 values: "0, w/3, 2*w/3, 0, h/3, 2*h/3". So these are the six possible values I would choose from to position the crop selection rectangle into the 9 segments I'm interested in, yes?

With a new image, 4032 x 3024, to split into nine I need 0, 2688, 2016, 0 for L, R, T, B for the first segment. I can do the math in my head and enter 0, 8064/3, 3048/3, 0, and Crop accepts the equations and gives me the desired margin values.

I'm hoping to use a formula so the input image dimensions could change and the crop transformations would not require any editing, but it appears that "w/3" is an illegal value, so please help with the syntax for entering an expression in the margin value text box, if that's possible at all?

Thanks again.
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Cutting large images into tiles

Post by jsachs »

You replace the "w" and "h" with the image width and height in pixels just as you did. Once you click OK, the cropping rectangle is saved using normalized coordinates (0.0 .. 1.0) so that if you run the transformation on another image the cropping rectangle is computed by multiplying the normalized coordinates by the new image width and height and thus it occupies the same relative position although its size and proportions may change.
Jonathan Sachs
Digital Light & Color
MarkT
Posts: 366
Joined: April 24th, 2009, 2:07 pm

Re: Cutting large images into tiles

Post by MarkT »

Oh, that is brilliant in its simplicity. Works beautifully - I have opened and run the workspace file on a few other images of varying dimensions, and it works perfectly.

Of course, you knew that would happen, but for me, this is close to magic.

Thank you for the support and clarity on the subject. Much appreciated!
Post Reply