Archive for the ‘tutorials’ Category

Panoramic photograph stitching — again

Sunday, April 3rd, 2011

In an earlier post, I described and implemented a method, that was published recently, to stitch together photographs from a panoramic set. In a comment this morning, Panda asked about the parameters that direct the region merging in the watershed that I used. This set me to think about how much region merging the watershed should do. The only limitation that I can think of, is that we need two regions: one touching the left image and one toughing the right. We can easily do this with a seeded watershed: we create two seeds, one at each end of the region where the stitch should be, and run a seeded watershed. This watershed will not create new regions. You should see it as a region growing algorithm, more than a watershed. However, the regions are grown according to the watershed algorithm: low grey values first. That insures that, when the two regions meet, it happens at a line with high grey values (a “ridge” in the grey-value landscape). The graph cut algorithm can now be left out: the region growing algorithm does everything.

(more…)

Measuring boundary length

Tuesday, September 14th, 2010

Oftentimes we segment an image to find objects of interest, and then measure these objects — their area, their perimeter, their aspect ratio, etc. etc. Measuring the area is accomplished simply by counting the number of pixels. But measuring the perimeter is not as simple. If we simply count the number of boundary pixels we seriously underestimate the boundary length. This is just not a good method. A method only slightly more complex can produce an unbiased estimate of boundary length. I will show how this method works in this post. There exist several much more complex methods, that can further improve this estimate under certain assumptions. However, these are too complex to be any fun. I’ll leave those as an exercise to the reader. :)

Because we will examine only the boundary of the object, the chain code representation is the ideal one. What this does, is encode the boundary of the object as a sequence of steps, from pixel to pixel, all around the object. We thus reduce the binary image to a simple sequence of numbers. In future posts I’ll explain a simple algorithm to obtain such a chain code, and show how to use chain codes to obtain other measures. In this post we’ll focus on how to use them to measure boundary length.

(more…)

Solving mazes using image analysis

Saturday, April 17th, 2010

I found an interesting submission on the File Exchange. It uses a very simple set of mathematical morphology filters to find the solution to simple mazes. I have several other solutions, so I decided to write an entry about the subject.

(more…)

Adding a parameter type to DIPimage

Monday, December 28th, 2009

In this post I want to show how to enable to DIPimage GUI to work with a new data type. In a previous post we developed a new class, dip_snake, for use with the function snakeminimize. The fully developed version of snakeminimize, which you can download here, integrates with the DIPimage GUI and uses DIPimage’s built-in automatic parameter parsing. We actually need to do something to DIPimage to get all that to work, because the dip_snake class is unknown to DIPimage. This post explains how to teach DIPimage about a new parameter type.
Note: This post is meant as a tutorial for people developing DIPimage applications, and contains nothing of interest to anybody else. If you’re not developing for DIPimage, you might want to look here instead.

(more…)

Implementing the dip_snake class

Monday, December 21st, 2009

In the previous post I showed how to implement active contours (a snake). I included the link to a set of files with a complete snake implementation to plug into DIPimage. This implementations uses a class called dip_snake. In this post I wanted to show how this class is defined using MATLAB’s new 1-file-style of class definitions. Well, “new” is not completely accurate, this feature has been around for a few releases already, but I’m slow to adapt… You’ll also learn how to make a class whose objects automatically create or update a figure window, much like an object of type dip_image does.

(more…)