Skip to content

Tag: picture

Gimp Small Miracles

Some times a good picture is ruined by a little detail or someone that shouldn’t be there. If you are willing to trade a complete portraying of the reality for a better photo, here are some tips for Gimp. Use them wisely.

Here is the original photo of two friends playing a game, and an unwanted stranger raising his arms right in the middle of the picture.

Here is the most useful tools from the Gimp tool box and how to use them:

Clone tool. The most common tool to create remove unwanted things. Usually you use them by getting a background theme and cloning it to cover what you want to hide. The best way to use this tool is when you have a not uniform background, like a wall or grass, where a small pattern repeats.

Free Selection (Lasso). When the clone tool is not enough because patterns are too big or too shapeless, the best is use the lasso tool. Get a good piece of the background or another object and them copy and paste over what you want to hide. Maybe what you need to select and copy is not in the same image you are working, you can get information from another picture and use in your main picture. This was what I had to do in this example.

Sometimes you have to change the brightness and contrast to match the pasted selection with the main picture.

Perpective tool. This is a very powerful tool because allows you to use a selection from another image but was taken from another point of view and you need to correct it’s perspective. By doing that you can retrieve a lot of information that your picture don’t have by taking them from another pictures. You can also use to fit a pattern.

Smudge tool. When you are handling uniform colors and straight shapes this is a good tool. You can smudge a pasted selection in the boundaries to it match with the main picture. You can also use it to stretch or squeeze shapes, but they have to be very color uniform to it work well. For more complex shapes you can use the IWarp filter.

So, I guess this is the most important about them. Another time I can do some videos showing how to use them better. In this work you can spot several little mistakes because I was very clumsy and in hurry, but the result is satisfactory.

Before

After

Next time ask people to get out of the way when taking a picture.

JavaFX, getting resources of inside your JAR

br flagTradução: há uma versão em Português desse artigo.

For some classes like javafx.scene.image.Image is easy load an image from a external resource like:

ImageView {
    image: Image {
        url: "http://example.com/myPicture.png"
    }
}

or a resource inside your own Jar file with the __DIR__ constant:

ImageView {
    image: Image {
        url: "{__DIR__}/myPicture.png"
    }
}

But for other classes loading a internal resource (inside your own jarfile) is not so direct. For example, in the article Parsing a XML Sandwich with JavaFX I had to place the XML file in a temp directory. A more elegant way would be:

package handlexml;

import java.io.FileInputStream;
import javafx.data.pull.*;
import javafx.ext.swing.*;
import javafx.scene.Scene;
import javafx.stage.Stage;

class Resource{
    function getUrl(name:String){
        return this.getClass().getResource(name);
    }

    function getStream(name:String){
        return this.getClass().getResourceAsStream(name);
    }
}

var list = SwingList { width: 600, height: 300}

var myparser = PullParser {
    documentType: PullParser.XML;
    onEvent: function (e: Event) {
        var item = SwingListItem {text: "event {e}"};
        insert item into list.items;
    }
    input: Resource{}.getStream("my.xml");
}
myparser.parse();

Stage {
    title: "Map"
    scene: Scene {
        content: list
    }
}

With a simple XML file called my.xml inside your package.



   
   
   
   
   

fileplace

And we get the same result as before, but all files inside our Jars.

References: