Sign in to follow this  
Followers 0
BoltBait

BoltBait's Seam Carving v2.2 Updated December 3, 2015

20 posts in this topic

The main purpose of seam carving is to reduce the width (or height) of an image without scaling (squishing) the image.

This effect calculates the line through your photograph with the least amount of changes and deletes that line shifting all pixels over to fill the gap. This is often called "content aware resizing".

Use

This effect is designed to be used with natural photographs. It is not designed to be used with an active selection. So, before running the effect, press Ctrl-D to remove any active selection.

Run the effect and click the OK button. One line of your image will be removed.

Note: Version 1.5 allows more than one line to be cut at a time. However, there is a limitation on how many lines can be safely cut at one time. You may find that only a few lines may be cut before you need to run the effect again so that more lines can be safely cut. Version 2.0 removes this limitation.

Please be patient when carving more than a few lines at a time. Due to the nature of the algorithm, the entire effect is run in a single thread. So, it may take a few seconds for the effect to show up after you move the slider.

If you wish to shrink your photograph even further, press Ctrl-F to redo the effect. Continue pressing Ctrl-F until your photograph is the desired size.

Protecting Elements

This effect will only carve out areas with full alpha. That is, it will ignore areas of your image where the alpha is set below 255.

You can use this to your advantage by selecting any area you wish to protect then use the Adjustments > Transparency plugin to lower the transparency slightly. Once you've finished with all of your carving, use the Adjustments > Transparency plugin to restore your image to full opacity.

SeamCarving15UI.png

Download (For paint.net 4.0.6+):

http://forums.getpaint.net/index.php?/topic/32048-v

You'll find it in your Effects > Photo > Seam Carving menu.

NOTE: This is slow on camera sized images. Sliding the slider up to 200 could take a couple of minutes to see anything. This is all due to the fact that it is running the algorithm in a single thread.

Updates

v2.2 - Improved messaging.  Added to my plugin pack.

v2.1 - Memory usage cut in half, speed improved, messaging improved.

v2.0 - Increases carves up to 200 lines at a time, removed "see it" option.

v1.5 - Carve more than one line at a time.

v1.1 - Fixed bug where it was producing jagged edges.

v1.0 - Initial release.

_________________

More info about seam carving here: https://en.wikipedia.org/wiki/Seam_carving

_________________

post-44727-0-57663300-1448764030_thumb.p

8

Share this post


Link to post
Share on other sites

I've tried it out on the example image from the Wikipedia page. It gave me a jagged edge.

carved-edge.png

 

If you wish to shrink your photograph even further, press Ctrl-F to redo the effect. Continue pressing Ctrl-F until your photograph is the desired size.


This seems rather silly. I don't think anyone would want to shrink their photo by only 1px, so why not make easier by adding a UI Control to iterate a loop? Granted you'd probably need to use a scratch surface, so it doesn't keep reading the same Source Surface every time.

 

Then again, I haven't seen your source code, or so I could be dead wrong. :roll:

0

Share this post


Link to post
Share on other sites

I've tried it out on the example image from the Wikipedia page. It gave me a jagged edge.

Yup. That's a bug. I'll work on a fix.

 

This seems rather silly. I don't think anyone would want to shrink their photo by only 1px, so why not make easier by adding a UI Control to iterate a loop? Granted you'd probably need to use a scratch surface, so it doesn't keep reading the same Source Surface every time.

 

Then again, I haven't seen your source code, or so I could be dead wrong. :roll:

The idea is to keep the UI as simple as possible while I work the bugs out of the algorithm.

Once the algorithm is solid, I'll see about improving the UI.

In the mean time, I think I'll move this thread to the development section.

1

Share this post


Link to post
Share on other sites

Ok, I think I fixed that bug. It seems fairly solid now, so... moving back.

0

Share this post


Link to post
Share on other sites

Ok, I think I fixed that bug. It seems fairly solid now, so... moving back.

I just ran it on a few images real quick. Looks good.

1

Share this post


Link to post
Share on other sites

I have read this post over and over and can not see what this would be used for. What am I missing? 

0

Share this post


Link to post
Share on other sites

I have read this post over and over and can not see what this would be used for. What am I missing?

Read this: https://en.wikipedia.org/wiki/Seam_carving

Look at the images along the right hand side of the page.

The main purpose of seam carving is to reduce the width (or height) of an image without scaling (squishing) the image.

0

Share this post


Link to post
Share on other sites

Ok, I see now. So does the plugin make the seams itself or do you draw the seams in? 

0

Share this post


Link to post
Share on other sites

I can see this plugin as being very useful on certain photographs.

 

Thank you, BoltBait.     :)

0

Share this post


Link to post
Share on other sites

Ok, I see now. So does the plugin make the seams itself or do you draw the seams in?

The plugin determines the best seam and then cuts it out automatically.

You can protect certain areas of your photograph (described above) or just let the plugin do its best guess.

It has a checkbox that you can use to see the seam it determines. This is purely to satisfy your curiosity. You would never select that option when using the plugin to carve a photograph.

EDIT: This option has been removed in version 2.0.

0

Share this post


Link to post
Share on other sites

OK, let me start by saying that I really do appreciate and like your PDN plugins very much. I also have tested a few "Content aware resize filters" in various programs, to be truthful, I'm not sold on the merits of this type of filter.

 

This one is a real head scratcher though. Is it not possible to just enter a horizontal and vertical resize dimension and be done with it?

0

Share this post


Link to post
Share on other sites

OK, let me start by saying that I really do appreciate and like your PDN plugins very much. I also have tested a few "Content aware resize filters" in various programs, to be truthful, I'm not sold on the merits of this type of filter.

 

This one is a real head scratcher though. Is it not possible to just enter a horizontal and vertical resize dimension and be done with it?

As stated above...

 

This seems rather silly. I don't think anyone would want to shrink their photo by only 1px, so why not make easier by adding a UI Control to iterate a loop? Granted you'd probably need to use a scratch surface, so it doesn't keep reading the same Source Surface every time.

 

Then again, I haven't seen your source code, or so I could be dead wrong. :roll:

The idea is to keep the UI as simple as possible while I work the bugs out of the algorithm.

Once the algorithm is solid, I'll see about improving the UI.

But, even as limited as the UI is right now, Ctrl-F makes this plugin really useful.

EDIT: UI has been fixed in version 2.0.

0

Share this post


Link to post
Share on other sites

OK, I have updated this plugin to version 1.5 to allow more than one line to be cut at one time.

The algorithm calculates all the safe lines through your photograph (x lines), then allows you to cut 1-x lines.

The number of lines you may cut at one time may be small. That's OK. Just cut them and run the effect again to calculate the next set of lines that can be safely cut.

(You may move the slider all the way to to the left to cut maximum lines and press Ctrl-F to do it again.)

I know you may be disappointed that you can't shrink the image all the way in one run, but, after cutting some lines, it is necessary for the algorithm to start over. This ensures the highest quality of the resulting image.

0

Share this post


Link to post
Share on other sites

Jagged edge again.
jagged-edge2.png

I suspect this is the cause? Intersecting/merged cuts.
intersecting.png

 

 

I know you may be disappointed that you can't shrink the image all the way in one run, but, after cutting some lines, it is necessary for the algorithm to start over. This ensures the highest quality of the resulting image.

 

This may be a dumb question. I understand it would not work if you were to read from the same Source Surface every time, but couldn't you use a scratch surface to get around this?

1) copy the Source Surface to a scratch surface when the effect opens

2) read the scratch surface to see where cuts can be made

3) write the cut image to the scratch surface

4) go to step 2

0

Share this post


Link to post
Share on other sites

The only time I've seen these jagged edges is when I rendered the purple lines on an image and then ran it again to cut them out.

Looks like I'm going to have to rewrite this effect from scratch. And, this time I'll use a temporary surface.

1

Share this post


Link to post
Share on other sites

Looks like I'm going to have to rewrite this effect from scratch. And, this time I'll use a temporary surface.

Complete rewrite done. Version 2.0 has been posted.

Due to the nature of the new algorithm, the "see it" option had to be removed. The new algorithm is iterative in nature, so the seams cut (after the first one) may not have existed in the original photograph.

1

Share this post


Link to post
Share on other sites

Version 2.1 published.

Improvements: Memory usage cut in half, speed improved, messaging improved.

This is just about ready to add to the plugin pack.

5

Share this post


Link to post
Share on other sites

OK, let me start by saying that I really do appreciate and like your PDN plugins very much. I also have tested a few "Content aware resize filters" in various programs, to be truthful, I'm not sold on the merits of this type of filter.

It allows you to resize the image significantly while keeping the subject and other objects in the image at full size within the frame. It's actually very useful.
0

Share this post


Link to post
Share on other sites

I like this plugin, real cool BoltBait. It serves the purpose real well, great job.   :)

 

Here is my first try at it. 

 

th_041-c_zpskwi6wvel.png

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0