Showing posts with label image processing. Show all posts
Showing posts with label image processing. Show all posts

Jul 1, 2013

Creating GIF animation in Ubuntu

From the manual of 'covert'
The convert program is a member of the ImageMagick(1) suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
The above quoted paragraph is an understatement of the abilities of convert. Besides many amazing acts, Convert is capable of creating of animated GIF images. To do so, type the following in terminal:
$ convert -delay 100 -loop 0 image*.png animation.gif
For more on ImageMagick, I recommend this blog post.

Jul 26, 2011

Algorithm for Handedness Detection of Fiddler Crabs

Members of the genus Uca are generally known as Fiddler crabs for the overgrown claw of the males. The following algorithm detects a male fiddler crabs handedness from a photograph. The algorithm was implemented using Matlab R2009a.


Mar 10, 2011

Fiddler Crab Handedness Detection

Fiddler Crab is the common name for the semi-terrestrial crabs of the genus Uca. The males have an oversized claw or cheliped. If the large fiddle claw is lost, males will develop one on the opposite side after their next molt.

I recently stumbled upon a solution for determining handedness of a male fiddler crab from its photograph.



The procedure assumes that the photo shows front side of the crab and the fiddle claw is horizontal or nearly horizontal in the photo. The basic idea is to find out the fiddle claw and the hole formed between two pincers of the claw. From determining the center of mass of these two regions on the 2D image, it can be detected whether the crab is left-handed or right-handed.

The photo was shot last year during an expedition near the mangrove area of Reju Khal in Cox's Bazar.

Mar 7, 2011

Automatic Species ID : Lepidochelys olivacea



The automatic species ID procedure I'm working on, follows these steps of image manipulation and decision making to detect Lepidochelys olivacea from a photo. For demonstration I'm using an image contributed by M.A. Hannan.

1. Convert RGB image to Lab color space
2. Enhance 'b' channel of the image


3. Complement 'b' channel of the image


4. Threshold complemented 'b' channel of the image with a predefined constant, 210 for this image


5. Dilate the resulting image


6. Fill the resulting image


7. Erode the resulting image


8. Mark the blob with maximum area


9. If area of the marked blob is not less than 30% of the image size then declare detection of LO

Feb 28, 2011

Automatic Species ID : Chelonia mydas



The automatic species ID procedure I'm working on goes through the following steps of image manipulation and decision making to detect Chelonia mydas from a photo. For demonstration I'm using an image contributed by Rachel Ruzgis to the image database of www.seaturtle.org

1. Convert RGB image to Lab color space

2. Threshold 'a' channel of the image with a predefined constant, 100 for this image

3. Fill holes

4. Erode image
5. Mark the blob with maximum area

6. If area of the marked blob is not less than 20% of the image size then declare detection of CM

Nov 9, 2010

Histogram smoothing with erosion

The idea of using erosion for smoothing histogram is actually borrowed from the realm of artificial terrain generation where it is a common practice. Recent experiments shows this is a better approach then using polynomial fit. Histogram is a one dimensional height map, after all. The result (smoothed histogram) closely follows the actual data points most of the time and structural property like rises and falls are well preserved.



The procedure is pretty straight forward, replace each entry in the vector containing the histogram with mean of that entry along with n entries backwards n entries forward. Boundary case arises when the index of the current entry is bellow n or beyond length_of_vector-n, I chose to keep those entries unchanged.


result = arr ;

for i=n+1:length(arr)-n
sum=0;
for j=i-n:i+n
sum = sum + arr(j) ;
end
result(i) = sum/(2*n+1);
end

Nov 1, 2010

Sea turtle carapace pattern as criterion for automatic species ID

The pattern seen on the carapace of sea turtles is one of the criterion used for identifying species, why not try to use this for automatic species ID as well ? The advantages of using this approach for automatic ID would be

  1. Works for photos taken in wide range of environments and lighting condition varying from the animal's natural habitat (under water) to decaying carcass of stranded animals found on beaches
  2. Only the carapace needs to be observed; other body parts, which decay sooner than the carapace in a dead animal, don't need to be observed
  3. Can work for both color and bw photographs
  4. Possibility of successful detection from broken or incomplete carapace if the key parts of the carapace is found
However, the challenges associated with this approach are also great. The challenges are encountered in two different phases, each of them are explained bellow.
  • Feature Extraction
    The sought after feature here is the pattern on the carapace. To understand the challenges in extracting this feature, we should understand its origin first. What we are referring to as pattern in common English as 'Pattern' is actually the network of ridge lines between scutes on the turtles carapace. This is true for all the species of Cheloniida family. For Dermochelys coriacea or leatherback turtle, the only species of Dermochelyidae family, the pattern is originated by the seven ridge lines on its back. Experimentation with several photograph taken in varying environment reveals that the ridge lines are best visible, hence extractable, in case of underwater photos.



    The above image shows the result of gradient magnitude, a standard edge detection algorithm, applied on a photograph followed by edge thinning on the resulting gradient magnitude image. But this does not yield good extractable features from photographs of stranded animals found on beaches, specially the decaying ones. Worse, due to presence of debris or other objects inside the frame, wrong part of the image is extracted instead of the carapace by the gradient magnitude finding operation.




  • Graph reconstruction
    The next challenge encountered is reconstruction of the pattern extracted from the photograph. Ideally, this would be the complete network of ridge lines. But the resulting image after feature extraction does not always have a complete network traced in most of the real life situations. So the graph reconstruction procedure should be robust enough to reconstruct a graph from incomplete or broken edges and at the same time be able to identify and discard edges that are not from the ridge lines on the turtles back.

Oct 29, 2010

Smoothing image historgram in MATLAB

%load rgb image
src = 'C:\rainbow.jpg';
rgbI = imread(src);
grayI = rgb2gray(rgbI);

%get image histogram
[counts bins]=imhist(grayI);

%fit histogram into polynomial to get smooth curve
fit = polyfit(bins,counts,10);
fit_samples = polyval(fit,bins);

%show histogram
plot(bins,counts,'.g',bins,fit_samples,'-b');


Image histogram in MATLAB


%load rgb image
src = 'C:\rainbow.jpg';
rgbI = imread(src);
grayI = rgb2gray(rgbI);

%get image histogram
[counts bins]=imhist(grayI);

%show histogram
bar(bins,counts);


RGB to Lab color transformation in MATLAB


%load rgb image
src = 'C:\rainbow.jpg';
rgbI = imread(src);

%convert to lab
labTransformation = makecform('srgb2lab');
labI = applycform(rgbI,labTransformation);

%seperate l,a,b
l = labI(:,:,1);
a = labI(:,:,2);
b = labI(:,:,3);

figure, imshow(l) , title('l');
figure, imshow(a) , title('a');
figure, imshow(b) , title('b');


The input image


and the output







image courtesy : Ashraful Alam