Gimp-Forum.net
How to scale an image RATIOnally? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: How to scale an image RATIOnally? (/Thread-How-to-scale-an-image-RATIOnally)



How to scale an image RATIOnally? - neverwind - 07-26-2018

Hello,

I've been struggling with a rather simple task for a while.
I do have an image which I want to scale in such a way, that the center of the image is less or not affected at all by the scaling than the edges.
I'll try to give a simple example with pixels, since I don't really know how to describe the effect:

1. We have an image with a 5 pixel width
2. We scale the image horizontally
3. The center column of pixels remains unaffected (not stretched)
4. The -1 and 1 columns of pixels get doubled (stretched)
5. The -2 and 2 columns of pixels get tripled (stretched more)

Is this achievable with Gimp and if so, can someone please give me a clue how to do that?

Many thanks,
Bobby


RE: How to scale an image RATIOnally? - rich2005 - 07-26-2018

If you need a 'logarithmic' type of scaling there might be a plugin - don't know of one.

Using standard Gimp 2.10 tools, no easy way that I know of. My thoughts.

Progressive scaling in sections.

Start with this, Canvas is resized to accommodate the extra width. Selection of the outer '2 strips' Throw in some guides as required. screenshots: https://i.imgur.com/EjGRYpi.jpg

Scale the the selection 200 % https://i.imgur.com/tysiWzD.jpg and anchor it

Select the now resized outer strip and scale 150% https://i.imgur.com/l9yIBia.jpg Anchor it

Repeat on the other side. All very tedious.


RE: How to scale an image RATIOnally? - Ofnuts - 07-26-2018

(07-26-2018, 10:04 AM)neverwind Wrote: Hello,

I've been struggling with a rather simple task for a while.
I do have an image which I want to scale in such a way, that the center of the image is less or not affected at all by the scaling than the edges.
I'll try to give a simple example with pixels, since I don't really know how to describe the effect:

1. We have an image with a 5 pixel width
2. We scale the image horizontally
3. The center column of pixels remains unaffected (not stretched)
4. The -1 and 1 columns of pixels get doubled (stretched)
5. The -2 and 2 columns of pixels get tripled (stretched more)

Is this achievable with Gimp and if so, can someone please give me a clue how to do that?

Many thanks,
Bobby

This looks like lens distortion, so see if Filters>Distorts>Lens distortion does it. Otherwise, Filters>Distorts>Whirl and pinch.


RE: How to scale an image RATIOnally? - neverwind - 07-27-2018

(07-26-2018, 11:31 AM)rich2005 Wrote: If you need a 'logarithmic' type of scaling there might be a plugin - don't know of one.

Using standard Gimp 2.10 tools, no easy way that I know of. My thoughts.

Progressive scaling in sections.

Start with this, Canvas is resized to accommodate the extra width. Selection of the outer '2 strips' Throw in some guides as required. screenshots: https://i.imgur.com/EjGRYpi.jpg

Scale the the selection 200 % https://i.imgur.com/tysiWzD.jpg and anchor it

Select the now resized outer strip and scale 150% https://i.imgur.com/l9yIBia.jpg  Anchor it

Repeat on the other side. All very tedious.

Thanks, Rich. That's exactly what I need to achieve, but then again...without actually doing it manually Smile


RE: How to scale an image RATIOnally? - rich2005 - 07-27-2018

Quote:That's exactly what I need to achieve, but then again...without actually doing it manually

Guessed that might be the case. You will need to ask one of the scripting experts for advice.

You could maybe also look at ImageMagick and search for something on non-linear scaling. There might be something in
https://www.imagemagick.org/Usage/distorts/ Also ask on the IM forum.


RE: How to scale an image RATIOnally? - denzjos - 06-28-2021

I was searching for something like that and found then : https://graphicdesign.stackexchange.com/questions/138705/gimp-non-linear-image-scaling
Used it on a extreme distortion with formule w*(2+1)*x/(2*w+x)
Original :
[attachment=6282]
Not very detailed (but it can't in this example) but corrected after perspective correction with gimp :
[attachment=6283]


RE: How to scale an image RATIOnally? - Ofnuts - 06-28-2021

(06-28-2021, 08:06 AM)denzjos Wrote: I was searching for something like that and found then : https://graphicdesign.stackexchange.com/questions/138705/gimp-non-linear-image-scaling
Used it on a extreme distortion with formule w*(2+1)*x/(2*w+x)
Original :

Not very detailed (but it can't in this example) but corrected after perspective correction with gimp :

Except that this particular case is really what the perspective transform is used for, because making the top and bottom parallel restores the scale.


RE: How to scale an image RATIOnally? - PixLab - 06-28-2021

I just generated a grid for test purpose (Filters > Render > Patterns > Grid...)
Then
Filters > G'mic_Qt > Deformations (I'm almost sure that in the "Testing" part of G'MIC you'll find something, I did not scroll down to the Testing directory/part, it's just too huge inside)

Anyway I think there is things there to start with like...

Cartesian distortion (I tried your equation see below)
conformal maps
logarithmic distortion
pixel push
and few others which at first glance seems to not do the job, but after tweaking many sliders....

[attachment=6284]
[attachment=6285]


RE: How to scale an image RATIOnally? - denzjos - 06-28-2021

@PixLab, I used this settings (example with squares after deformation) :
[attachment=6286]

(06-28-2021, 10:48 AM)Ofnuts Wrote:
(06-28-2021, 08:06 AM)denzjos Wrote: I was searching for something like that and found then : https://graphicdesign.stackexchange.com/questions/138705/gimp-non-linear-image-scaling
Used it on a extreme distortion with formule w*(2+1)*x/(2*w+x)
Original :

Not very detailed (but it can't in this example) but corrected after perspective correction with gimp :

Except that this particular case is really what the perspective transform is used for, because making the top and bottom parallel restores the scale.

@Ofnuts, I know how the perspective transform work, but in my case I saw after the perspective transform that the proportions of the black door on the left side was't in proportion to the real scene, so after cropping the very big result, I scaled the picture so that the black door had the right dimensions. I saw that the picture from left to right was logarithmic stretched so I searched for a solution and found the link to solve this with G'Mic-Qt. I often searched for such a tool when I make a panorama image and the proportions of the result are not right. This must do the job.


RE: How to scale an image RATIOnally? - PixLab - 06-28-2021

(06-28-2021, 04:56 PM)denzjos Wrote: @PixLab, I used this settings (example with squares after deformation) :

Yes, this looks good and also very promising as you can tweak/modify the formula for more fine tune or whatever needs.
Well done!