Jump to content
How to Install Plugins ×

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


BoltBait

Recommended Posts

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

  • Upvote 8
Link to comment
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:

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
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.

  • Upvote 1
Link to comment
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.

Link to comment
Share on other sites

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

 

Thank you, BoltBait.     :)

Link to comment
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.

Link to comment
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?

Plane_Sig2.gif

Link to comment
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.

Link to comment
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.

Link to comment
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

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
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.

  • Upvote 1
Link to comment
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.

  • Upvote 1
Link to comment
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.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

  • 2 years later...

I've just tried using this with version 4.0.21 and while the horizontal one works (albeit it being a bit annoying it can only go at 200 at time but understandable), the vertical one crashes paint.net immediately upon clicking it. I've attached a crash report. 

image.png

Link to comment
Share on other sites

2 hours ago, a4955 said:

I've just tried using this with version 4.0.21 and while the horizontal one works (albeit it being a bit annoying it can only go at 200 at time but understandable), the vertical one crashes paint.net immediately upon clicking it. I've attached a crash report. 

 

 

Thanks for the crash report.  I'll take a look and see what's going on.

Link to comment
Share on other sites

  • 4 weeks later...

I've searched on the plugin index but can't find anything like this plugin that can add pixels like the demo on the Wikipedia page.

 

Have I just not searched correctly, or is there nothing that can increase the size of an image with the same seam algorithm?

Link to comment
Share on other sites

Content aware fill has just been released, try that:

 

Link to comment
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.

×
×
  • Create New...