Sign in to follow this  
Xhin

Cubic Transformation -- now version 2 (shape options are sliders instead of checkboxes, a new effect, better quality)

Recommended Posts

Distort > Cubic Transformation

 

This plugin started as an attempt to replicate the "rectangular aspect" of my Rectangular Inversion plugin without the inversion part of it. By messing around with it further though I noticed that there was something 3D happening with it.

 

This plugin will distort an image one of four interesting 3-D ways. The "corners" are mapped to the image's dimensions so you can get things that are more "square" or "rectangular" by changing the image's height-to-width ratio.

 

The way this plugin works is somewhat interesting, I'll include a snippet about that below. In any case, let's take a look at it:

 

Im7mTK5.png

  • Shape Type -- Can be either "Pyramid" or "Tube".
  • Curve Type -- Can be either "Concave" or "Convex". Honestly I don't really know what to name these -- concave seems to be the inverse of convex, but in another sense Pyramid (of either type) is the inverse of Tube. This will probably get fixed in a later version. In any case, these four options are your four types of transformations.
  • Intensity -- Increases the intensity of the distortion effect.
  • Pan/Rotate -- This is basically a pan tool, but since you're dealing with 3D spaces, sometimes "rotate" makes more sense (particularly with Tube transforms).
  • Zoom -- zooms in or out on the image, but preserves the transformation settings. Zooming in or out on the resulting image would be quite difficult because it's mapped to the image dimensions. In any case, different intensities seem to have some mild zooming effects of their own, so this will help correct them among its other uses.
  • Quality v0 -- As with the rest of my distortion plugins, this is faked-out and is just a light blur. I'll introduce an update at some point that addresses all the quality sliders at once.

 

Let's take a look at what these settings do:

 

uhfPOTY.png

 

Here's a base image for the sake of comparison. Nothing fancy, just a black-and-white spiral gradient.

 

9rSB4Qn.png

 

Here's your default setting -- a Pyramid Concave transformation. Note the mapping to the corners of the image and how the rest of the image bends around those lines.

 

FNe22Va.png

 

Here's a Pyramid Convex transformation. This setting tends to turn circles (and everything else really) into rectangles, so it should be useful for creating picture frames.

 

6VKS2L7.png

 

Here's a Tube Concave Transformation. This also makes things more rectangular, but makes the edges turn inwards rather than outwards. At higher levels of intensity, the tube shape type lives up to its name.

 

LOYHOpy.png

 

Here's a Tube Convex Transformation. It's similar to the pyramidal convex one, but there are subtle differences and bigger differences at higher intensities.

 

HJKCQEc.png

 

This is still Tube Convex, but I've increased the intensity. It now looks quite a bit like you're looking into a curved box.

 

NbkgIn9.png

 

Same as the above, but I've rotated. You can now see that it isn't a box but instead some kind of tube-shaped thing. Rotating with Tube Concave is instead like looking at two intersecting tubes, and Rotating with either of the Pyramid settings is really just panning the source image around.

 

DPaeMUr.png

 

Lastly, Zooming will zoom out on the source image. You can see here that the pyramid convex nature of the image is preserved and only the "texture" of it has changed. This should be the case for the Tube settings as well, but instead it feels like you're actually zooming in and out on the 3D structure. It's got to be some kind of optical illusion. Neat effect though.

 

Still to do

  • Get the quality slider working obviously
  • Release the source code
  • Maybe rename / adjust things when I use the plugin some more.

 

What's happening under the hood

 

This is worth having a section for because it's kind of interesting. Not essential though, so skip it if you want.

 

What I've done with this plugin as well as the Rectangular Inversion one is to convert the image to something I call "Rectangular Coordinates" -- basically they're polar coordinates, but they have an additional component, which is the distance to whatever edge of the image they hit with their polar angle. With the rectangular inversion plugin, I'm subtracting the polar distance from the edge distance and then converting it back to cartesian coordinates.

 

With this one, I'm getting a ratio between the edge distance and the maximum edge distance (in this case the line between the center and one of the corners) and dividing the polar distance by that. This basically means that pixels along the diagonals are normal and pixels that are horizontal and vertical are warped by the most, with everything else in between them.

 

The "Concave/Convex" type affects whether the edge-seeking formula looks for the closest or furthest edge to determine where the edge actually is (in a choice between the closest x-edge and the closest y-edge). The "Shape" type, meanwhile, determines whether the ratio is edge distance/maximum edge distance or maximum edge distance/edge distance. I've been working with polar coordinate-based effects for a while now and I get a sense that what's happening is you're inverting or rotating the graph itself when you do things like this.

 

Download Link

https://github.com/Xhin23/Paint.net-Plugins/blob/master/Cubic_Transformation.dll

Edited by Xhin
  • Like 4

Share this post


Link to post
Share on other sites

Cubic Transformation Version 2

 

Through quite a bit of work, I've turned the "Shape Type" and "Curve Type" settings into sliders. They also go quite a bit higher than the old settings worked, allowing you to, for example, turn images hyperbolic. I also added a new setting which lets you move around better, and I updated the quality setting to what'll probably be the final version for my quality sliders.

 

oOHwLdp.png

  • Shape -- The new version of "Shape Type". -1 is equivalent to Tube and +1 to Pyramid in Version 1.
  • Rectangular Intensity -- The new version of "Curve Type". -1 is equivalent to Convex and +1 to Concave in Version 1. Setting it to 0 seems to make the effect elliptical.
  • Source Pan -- This is what the old Rotate/Pan is now called. While it's technically accurate now, it doesn't always work how you'd expect it to, and sometimes feels more like rotation than panning due to 3D effects.
  • Dest Pan -- A new effect that lets you move around the resulting affected image.
  • Quality -- An actual quality slider -- 1-5 work how you'd expect them to. However, I've also included a 6 and 7. These are pretty extreme, equivalent to 10 and 20 respectively. Potentially useful for very very high quality on high-distortion images if you don't mind waiting several minutes. I wouldn't recommend running 7 on large images, but 6 is feasible if your graphics card can handle it.

 

I've also removed the Intensity effect. The natural intensity of the effect is now 3, so you might get slightly different results with default settings. However, there was a lot of overlap between intensity and shape/rectangular intensity, so you can still get whatever you want by adjusting those sliders instead.

 

Let's take a look at the changes.

 

zJFWcbd.png

 

I'm using the same source image so you guys can compare the different versions.

 

BWRdqsB.png

 

With default +1 Rectanguar Intensity, setting Shape above +1. You could call this a Superpyramid Concave.

 

30xfeqr.png

 

Putting Shape to 0.

 

0wtSwZP.png

 

Putting Shape below -1. A Supertube Concave effect maybe.

 

XnfRkSg.png

 

Keeping Shape at the default +1, putting Rectangular Intensity higher than +1. Pyramid Superconcave.

 

8NsPjPX.png

 

Putting Rectangular Intensity at 0. Whatever effect you're doing is just elliptical and has no relation to the corners at all.

 

heMZGSJ.png

 

Putting Rectangular Intensity below -1. Pyramid Superconvex.

 

6Qz9c0p.png

 

Keeping the default settings, but messing around with the Dest Pan effect. This doesn't quite do what you'd expect it to do either, but you can get some pretty neat effects, which is what's important in the end.

 

A note of caution (or I guess lack thereof)

 

Hv4Aok4.png

 

If you play around with this effect enough you can go so far that paint.net can't render what you're looking at and instead you'll get solid color regions like this. It's also possible to overflow and get some really weird inverted effects (which might be worth exploring in a different plugin). None of this kind of thing breaks paint.net, but it might look like a bug when it's not.

 

Still to do

  • Look into improving the quality slider for upscaling as well as downscaling. At the moment you can get a lot of very pixellated effects which probably isn't useful.
  • Hopefully using this effect more will let me understand how Source Pan and Dest Pan actually work. At the moment they're both useful but neither does what you'd think it would.
  • Update the docs here. I'll probably do this in bulk with all of my version 2 plugins.
  • Release the source code.

Download link (same as the old download link)

https://github.com/Xhin23/Paint.net-Plugins/blob/master/Cubic_Transformation.dll

Edited by Xhin
  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this