Live data from Hacker News

Content-aware image resizing in JavaScript

trekhleb.dev

11–20 of 68 posts

Re: Content-aware image resizing in JavaScript

#11

Is there an opposite of this, where it will expand an image size?

It'd be pretty interesting to train an ML model. You could generate a bunch of training examples: downsize lots of images, then use the upsized versions as targets.

It's not quite the same thing as superresolution, since it's seam carving.

Re: Content-aware image resizing in JavaScript

#12

Is there an opposite of this, where it will expand an image size?

Yeah, I believe Seam Carving paper did this. Pretty simple, find the low-energy path and do linear interpolation between the two neighboring pixels (I think it also introduced some tricks to find n low-energy paths at once to avoid inserting into the same path again and again).

But like the top comment pointed out. This algorithm is easy to implement and interesting, but in real-world examples are not better than salient object detection + cropping.

Re: Content-aware image resizing in JavaScript

#13

Is there an opposite of this, where it will expand an image size?

That's more related to a problem known as infilling. Generally throwing out information is a lot easier than generating it. You can do some statistical things by sampling other points of the image into newly created "gap" but it will probably look bad if fully automated, at least on big changes.

There's an obvious version of the algorithm in that direction. For one line "seam", it's easy enough, you just pull data from either side. But repeatedly applying it the more often your new "seams" end up next to something already estimated, the less real information there is - I suspect this becomes visually noticeable pretty fast.

Re: Content-aware image resizing in JavaScript

#17
post #4

I wish there were more of such interesting and educational articles with great examples and explanations.

Yaz, Right???

One of the biggest complaints I have about HN is that it promotes really crappy "Look at me! I just learned a thing and wrote a 300 word blog doing a crappy job explaining it because I don't really get it but want to pad my CV..."

This article is exceptional. Thank you OP.

Post reply on HN