5
$\begingroup$

I am trying to find out which way the whale is moving. So I have an image of the whale swimming in the water and I want to find out where is it located and which direction does it swim (with respect to X/Y coordinates of the image).

enter image description here

For example here the angle is approximately 30 degrees in respect to X coordinate.


So my idea was to use canny edge detection to extract edges, construct a matrix from the points of the edges, calculate SVD and use the U matrix from SVD as a rotation matrix to get the angle.

So I have done something like this in python:

enter image description here enter image description here

Where the first image is the starting image, the second one is the edges, and the third one is the scatterplot with points from the edges and the red arrow is a direction of the angle I got from the SVD. The angles I got

Angle 146.73
Angle 135.08

are not even close to real angles (which are approximately 30 and 85 degrees).


I have tested that I get a correct angle when I SVD the gaussian matrix, which I rotated by some degree.

This is my first post, so if you need some clarifications (code that I used, explanation why I think this approach will work or anything else), please let me know.


So am I on the right track to find where the whale is going (and just made some silly mistake) or should I use another idea?

$\endgroup$
5
  • $\begingroup$ Hi. You mentioned using color separation (red channel) to try to improve the contrast. Did you look at HSV or CMYK? I had a quick look, and both the saturation from HSV or the Cyan-K from CMYK give really high contrast on the whale. Both turn the whale black and the water light colored. Might be of some help in getting better edge detection. $\endgroup$
    – JRE
    Sep 8, 2015 at 7:41
  • $\begingroup$ @JRE Actually I just took R component from RGB matrix of the image. Can you please share the implementation you used? $\endgroup$ Sep 8, 2015 at 7:45
  • 1
    $\begingroup$ All I did was use GIMP to separate the colors to see what kind of contrast I could get. It looks like you are using Matlab. There are various functions in the Image Processing Toolbox for doing colorspace changes. See manual here: mathworks.com/help/images/color.html?nocookie=true $\endgroup$
    – JRE
    Sep 8, 2015 at 7:56
  • $\begingroup$ @JRE thanks will try to investigate this approach $\endgroup$ Sep 8, 2015 at 8:00
  • $\begingroup$ @SalvadorDali, Have you reviewed my answer? Could you please mark it? $\endgroup$
    – Royi
    Feb 12 at 10:26

3 Answers 3

1
$\begingroup$

I wouldn't rely on edges as they are not connected and foam/waves also generate them.

I would rely on the contrast between the colors of skin, water and foam, to get a solid blob.

Possibly a two step process: discard the more saturated pixels (the sea), then among the achromatic keep the dark ones. After experimenting I saw that erosion can be useful to get rid of unwanted residues.

In the end you should get a big blob, and determine its dominant orientation (equivalent ellipse of inertia, Feret diameter, most distant points...)

Unsaturated pixels:

enter image description here

Dark pixels:

enter image description here

Combination:

enter image description here

Eroded:

enter image description here

Blobs and ellipse of inertia:

enter image description here

enter image description here

As there is a risk of blob fragmentation, you can consider merging the largest blobs.

$\endgroup$
0
$\begingroup$

My approach:

  1. Preprocess your image to maximize contrast: for a start, this might really just be the red channel for example, but my gut feeling is that you can transform the image to a different color model and e.g. use luminance instead, and get higher contrast. Low pass to suppress fotographic noise.
  2. Edge detection is a good approach, but I'd just go for the high-pass version of the image. Threshold if appropriate. Cut down if appropriate.
  3. Use Principal Component Analysis to find the main direction of that, i.e. the vector which points in the direction where the highest variance in values is.
$\endgroup$
3
  • $\begingroup$ My first approach also was about red channel, but I found that it is not really different even from blue channel (which was surprising for me be because I guessed that blue is all over the place and irrelevant). $\endgroup$ Sep 8, 2015 at 7:30
  • $\begingroup$ In my opinion, working on the luminance is the worst choice. It makes the whale almost invisible. Red is a little better. $\endgroup$
    – user7657
    Oct 8, 2015 at 9:16
  • $\begingroup$ @YvesDaoust well, in the case, since most sensible color models try to find orthogonal bases in color space , linear algebra says that if the information in the luminance is minimal, the information contained in the other channels is maximized :) $\endgroup$ Oct 9, 2015 at 8:15
0
$\begingroup$

I found a really nice visual object tracking approach in Raphael Candelier - Tracking Object Orientation with Image Moments:

enter image description here

It looks it fits your problem perfectly. If you share more images we could give it a try with MATLAB Code.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.