Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feature extraction and take color histogram

Tags:

I am working on an image processing feature extraction. I have a photo of a bird in which I have to extract bird area and tell what color the bird has. I used canny feature extraction method to get the edges of a bird.

How to extract only bird area and make the background to blue color?

openCv solution should also be fine.

enter image description here

import skimage
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt

import os
filename = os.path.join(os.getcwd(),'image\image_bird.jpeg')
from skimage import io
bird =io.imread(filename,as_grey=True)
plt.imshow(bird)

enter image description here

from skimage import feature
edges = feature.canny(bird,sigma=1)
plt.imshow(edges )

enter image description here

Actual bird image can be taken from bird link

like image 266
Sumeet Kumar Yadav Avatar asked Sep 03 '18 17:09

Sumeet Kumar Yadav


1 Answers

  1. Identify the edges of your imageSobel edge map

  2. Binarize the image via automatic thresholdingbinarized edge map

  3. Use contour detection to identify black regions which are inside a white region and merge them with the white region. (Mockup, image may slightly vary) Mockup of the merged mask

  4. Use the created image as mask to color the background and color it final image This can be done by simply setting each background pixel (black) to its respective color.

As you can see, the approach is far from perfect, but should give you a general idea about how to accomplish your task. The final image quality might be improved by slightly eroding the map to tighten it to the contours of the bird. You then also use the mask to calculate your color histogram by only taking foreground pixels into account. Edit: Look here:

  1. Eroded mask

eroded mask

  1. Final image

Final image with eroded mask

like image 132
SilverMonkey Avatar answered Sep 21 '22 13:09

SilverMonkey