Monday, September 12, 2011

Binary operation

Morphological operation like erosion and dilation are very useful for for image isolation. However these types of treatments often disfigure the image that it becomes of little use for further processing. Binary operations were based on these basic functions were developed to compensate for this flaw.

Opening is where one erodes the image then dilates it using the same structuring element. What it does is is that it removes all white regions whose dimensions don't fit the structuring element. If we consider the regions  with a value of zero as holes, the operator would 'open' those holes, hence the name.

Closing on the other hand is an erosion followed by a dilation using the same structuring element. It removes black regions smaller than the structuring element. It is like the closing of the holes in an image.

For this activity, we will use these operators to estimate the area of simulated cells. We will also try to isolate  cancer cells inserted with the normal cells.

First we cut up the image into 12 256 x 256 pixel images. this is to reduce the burden of the program to the computer. Then we convert them into binary images as shown below.


As we can see the images formed are very noisy. This can be fixed by opening the image using a circle that is a bit smaller than the cells as a structuring element. The images produced is shown below.


We then recombine these images back into one image:



We can see that although the noise has been dealt with, many of the cells are clumped together which may cause our average to have large error. To obtain the area we use bwlabel to index each structure and hen created a program to count for each pixel in each structure. the value we obtained was 710.28 ± 522.88 pixels. As expected, the standard deviation of the area was large.

Using the average we obtained, we will try to isolate the simulated cancer cells from the image below.


Using a structuring element that is a bit larger than the radius of the original cells we obtain the image below:



As you can see, I was able to isolate the circles larger than the original cells(cancer cells). Since this was an easy activity, I give myself a 10/10

Monday, September 5, 2011

Morphological Operations

Morphological operations are post processing done to binary images in order to extract information or remove unnecessary structures. In this activity, we discuss the different types of morphological operations that can be done in scilab.


Dilation

This morphological operation is a treatment that increases the surface area of the areas that have a value of 1. The dilation between set A and B is defined as the set of all z's which are translations of a reflected B that when intersected with A is not an empty set. That sound pretty complicated, and to my understanding, it means to use B to increase the surface area of A as seen below:



The red regions are the parts of A that overlap with B, while the yellow shaded region is the dilated part of the original structure. Note, however that this is only my understanding of the use of dilation. When I wrote a code for dilation what happened is this:

We can see that although it was correct for the most part, there have been some errors in my predictions. The most obvious error is when using either the cross or diagonal structuring element. In my predictions the corners of the dilated image would be chipped like a sawtooth. Instead what I obtain is a corner with only 1 pixel removed.


Erosion

Like an opposite to dilation erosion is used to decrease the the area of the regions with the value of 1. The erosion of sets A and B is defined as the set of all points z such that B translated by z is
contained in A. Erosion is designed such that the reduction in the area of A is defined by the structuring element B.

Unlike for dilation which I just covered the edge of the image with the structuring element, for erosion I chose an origin for the structuring element. This origin is then placed on each pixel of the image and if the whole structuring element is not inside the image, that pixel will be equal to zero. We would then obtain an eroded image as shown below:


Where the red regions are the eroded parts of the image. Writing the code for erosion we obtain these images:

Again, most of my predictions were correct however, if we look at the eroded images for the annulus and cross with the diagonal structuring element. the program obtained a different image. This may be due to my arbitrary assignment of the origin.

Thin/Skel

a) Original Image, b)Skel, c) Thin
Thin/ Skel are other morphological transforms that one can use using the SIP Tool in scilab.The Skel function "skeletonizes" the image by creating a hypothetical frame for the image. The thin function like its name says, thins the image. This is done eroding the borders of the image.

All in all it was an easy activity, however, I found drawing my predictions (the original plan) quite a hassle so I used paint for my predictions. For this activity I give myself an 8/10

Thursday, September 1, 2011

Enhancement by Histogram manipulation

I HATE THIS ACTIVITY!!There are two reasons why I'm late in posting my activities for 186, one is the submission for SPP, and the other is this activity. It took me only now to make the code for this work so I was only able to post this now.


Manipulation of an image’s histogram is one of the ways in which we can improve the quality of an image by enhancing some features of the image which are not normally seen with the naked eye. This is done by back projection using the cumulative distribution function (CDF) of the image. This back projection is shown below:
By doing so, we can enhance the image in such a way that under and overexposed parts of the image would be normalized thus increasing the amount of detail in the picture
Take Figure below for example. It is an underexposed picture of a seaside restaurant with its CDF shown:

Now we take an ideal, in this case linear CDF and use it  to enhance the image like so:
We can see that the CDF of the fixed image has the same form as the ideal CDF that we used. However note that the image brightened a little. This may be attributed to the fact that the original image was saved using a .jpg format. We learned from previous activities that .jpg has a lossy compression therefore there is little information left in the dark regions of the picture. Even with histogram manipulation, we cannot recover information that is not present anymore.
Also note that the human senses are generally non-linear so I tried different CDF’s with result shown below:
Finally I think creating a code for histogram manipulation is quite a hassle, thankfully some graphics manipulation software have already incorporated this technique in their programs. One of those programs is Gimp:


It is actually quite annoying to use histogram manipulation in Gimp. It was so easy that it made me think ’what the hell was I writing all those codes for… ’
All in all, I think this activity was quite the hassle, back propagation might seem simple when looking at Fig. 1 but when actually applied to code, it was quite confusing. My pride on not asking others for help also didn’t help. That’s the reason I’m posting this only now. Still I give myself a 6/10 for this activity, at least I finished it… >.<