Archive

Archive for the ‘Image Processing’ Category

paw detection

July 11, 2012 Leave a comment

really really Awesome post. — A paw detection using Python ndimage.

Categories: Image Processing, Python

Random Picking

July 3, 2012 Leave a comment

Here’s some interesting link I found from ‘ IMAGE AND VISUAL REPRESENTATION GROUP IVRG ‘

1. The free book of ‘joy of visual perception

2.CVonline: Vision Related Books including Online Books and Book Support Sites

Their algorithmRadhakrishna Achanta and Sabine Susstrunk, Saliency Detection using Maximum Symmetric Surround, International Conference on Image Processing (ICIP), Hong Kong, September 2010.

is dealing with the problem of “salient regions comprise more than half the pixels 
of the image, or if the background is complex, the background gets 
highlighted instead of the salient object. “. Tested on several images, though not working for all cases, but it’s quite a nice saliency detection since it dose avoid some problems  by most of the saliency detection — focusing mostly on high frequency, dense edge  region.

   

Also, it seem that a website is built based on their research for automatically cropping image to give the best composition.

 

Mean Shift Segmentation

June 13, 2012 Leave a comment

There are actually two steps in Mean-shift image segmentation: mean-shift filtering and then some merging and eliminating for segmentation. here’s a paper well states the process. I found it quite clear and easy to understand. Below are some notes on Mean Shift Segmentation.

1. Based on non-parametric density estimation, no assumptions about probability distributions, and no restriction on the spatial window size (which is different from bi-lateral filtering)

2. Spatial-range joint domain (x, y, f(x, y)), spatial domain refers to image spatial coordinates, while range domain refers to image dimension, such as gray image (1), rgb color image (3), etc

3. Finds the maximm in the (x, y, f) space, clusters close in both space and range correspond to classes.

4. The 3 parameters (such in EDISON) are :

sigmaS: — normalization parameter for spatial

sigmaR — normalization parameter for range domain

minRegionSize  — minimum size (lower bound) that a ‘region’ is declared as a class

     To understand the two normalization parameter, sigmaS and sigmaR, think about the window size in the kernel function in the kernel density estimation. It controls the ‘range’ or say smoothness of the kernel, or how fast the kernel decays. Larger the normalization parameter is, it is smoother in the corresponding space( either spatial or range), or decays slower. A ZERO value corresponds to a delta function, which only concentrate on the center, i.e. the filtering output will be the same as the input, all details (each pixel) are remained. Larger sigmaS smoothes the spatial, while larger sigmaR smoothes the range (color domain).  And from the results I obtain, singmaS is much more sensitive as compare to sigmaR.

The most well known open source for mean-shift, which is also very fast, is EDISON. If you want to use it in Matlab, there are also some wrappers.

Left: Original, Middle (4, 4, 5), Right: (10, 4, 5)

 

ImageJ

June 12, 2012 Leave a comment

Here’s the wonderful imageJ <http://rsbweb.nih.gov/ij/plugins/index.html&gt;

Sometimes, one can really learning something by just reading these fundamental algorithmes.

And here’s a version of mean-shift.  And  a sklearn python version.

Here’s a nice comparison of different clustering method.

Categories: Image Processing, Java

An objc image processing package

April 17, 2012 Leave a comment

Here’s one that objective-C based image processing package.

Install OpenCv with Python Binding on MacOS

April 4, 2012 1 comment

I had tried several versions of install opencv on my mac that can be used in python.

Here are lessons — use the python provided by MacOS, you may have the following problem if you are using other versions.

Steps:

– Use python by MacOS, which you should be able to finda and locate, e.g. the link /usr/bin/python    (my version is Python 2.7)

I found that I can not use the python I installed somewhere else, such as </Library/Frameworks/Python.framework/Versions/2.7/>

– I used the brew to install opencv:

http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port?highlight=%28%28InstallGuide%29%29

   $sudo brew install opencv  

It enventually install it to  </usr/local/Cellar/opencv/2.3.1a>

– Next step, you need to add the path </usr/local/Cellar/opencv/2.3.1a/lib/python2.7/site-packages> to your PYTHONPATH

If you check the sit-packages folder, it should include two files: cv.py and cv2.so

So, change your ~/.profile to include the following line:

export PYTHONPATH=”/usr/local/Cellar/opencv/2.3.1a/lib/python2.7/site-packages:${PYTHONPATH}”

Otherwise, whenever you would like to import the cv, you will have to first include the path in your python code, something like this:

sys.path.append(‘/usr/local/Cellar/opencv/2.3.1a/lib/python2.7/site-packages’)

Now, time to do the test:

I couldn’t find the example folder of python by the package installed by brew.

So I went ahead and use the previous download one, which is a full package opencv:

$ls ~/Documents/OpenCV-2.3.1/samples/python             (where you will be able to find the delaunay.py file, then go ahead to run it)

$ python ~/Documents/OpenCV-2.3.1/samples/python/delaunay.py

Nice , now it’s running, finally 🙂

ImageMagick – resize image

February 29, 2012 Leave a comment

ImageMagick  is really a convenient tool for batch image process.

Install from here:  http://www.imagemagick.org/script/index.php

For my installation I simply choose what they recommended: x86 dynamic version.

Now, able to batch resize use command like( this will resize all the jpg image under the current folder (overwrite the original one) with a rescale ratio %25 :

mogify -resize %25 *.jpg

Here’s a link with more information:

http://www.imagemagick.org/script/command-line-processing.php#geometry

http://www.gimpusers.com/forums/gimp-user/11032-scaling-image-via-the-command-line

 

Use help to get all the command line functions provided.

$ mogrify -help

Usage: mogrify [options …] file [ [options …] file …]

 

Python OpenCV Crop Image

February 16, 2012 Leave a comment

cvIm = cv.LoadImage(imfile)
cropped = cv.CreateImage((roi_width, roi_height), cvIm.depth, cvIm.nChannels)
src_region = cv.GetSubRect(cvIm, (roi_x, roi_y, roi_width, roi_height))
cv.Copy(src_region, cropped)

By the way, here’s a link for using openCV in matlab.

ColorPy – A Python package for handling physical descriptions of color and light spectra.

February 7, 2012 Leave a comment

Though simple, but color converting is still a complex process which needs a lot of attention for details and the correct understandings. Even PIL does not include a comprehensive package. Well, just come across this website today, which introduces a nice module for color manipulation.

<http://markkness.net/colorpy/ColorPy.htm>

Online Shopping and the Problem with Pictures – Jacqueline Conard – Research – Harvard Business Review

February 6, 2012 Leave a comment

A very nice article, and the experiment is interesting. As for visual based e-shopping, beyond the chance that good quality image that can bring more faith and trust when they buy the goods, the way that the image present the content – how good it makes the balance between reality and the magic of color and light – will also make great impact on customers in a long run.

Online Shopping and the Problem with Pictures – Jacqueline Conard – Research – Harvard Business Review.

openCV and Python

January 24, 2012 Leave a comment

First few things to check out for openCV:

1. Install Open CV on Ubuntu 

2. Cookbook

3. A StackOver Link for using openCV by Python

pygame

       sudo apt-get install python-pygame
Here’s a start-up example 🙂
OpenEXR
Categories: Image Processing, Python

Detect Duplicate Image using Python

July 30, 2011 1 comment

To detect the exact duplicated image, using Md5 hashing (Python).

In finding the exact duplicated image, using a dictionary to store the hash value. If exact hash value is obtained, the current processing image is defined as the duplicated one. The already-read-in image is defined as ‘Representative Image

Function findDupImgMd5 returns the list of the duplicated image, and the hash results ( with image ids fall into each hash bin) .

The main program writes the list of duplicated image, the hash results into txt file. Also move a copy of the duplicated image as well as their Representive Image into the DupImg folder.


# FindDupImage.py

import os, glob
import Image
import hashlib
import shutil

def Imge_md5hash(im_file):
    im = Image.open(im_file)
    return hashlib.md5(im.tostring()).hexdigest()

def findDupImgMd5(data_path):
    hashdict={}
    deletionList=[]

    for infile in glob.glob(data_path + os.sep +"*.jpg"):
        fileNP, ext = os.path.splitext(infile)
        ids = fileNP.split(os.sep)
        hash_result = Imge_md5hash(infile)
        if hashdict.has_key(hash_result):
            deletionList.append(infile)
            hashdict.setdefault(hash_result, []).append(ids)
    return deletionList, hashdict

if __name__=="__main__":

    folderPath = r"your-image-data-folder"
    deletionList, hashdict = findDupImgMd5(folderPath)

    print("Start to save the data")

    with open("dupImageList.txt", 'wb') as ofile:
        _=[ofile.write(item+"\n") for item in deletionList]

    with open("hashDupImageDict.txt",'wb') as ofile:
        _=[ofile.write(k+"\t"+ "\t".join(v)+"\n") for (k,v) in hashdict.items()]

    """Copy the duplicated image to Dup-folder, renamed with
    hash-code and original id"""

    DesFolder = os.path.join(folderPath, "DupImg")

    if not os.path.exist(DesFolder):
        os.madir(DesFolder)

    for k,v in hashdict.items():
        if len(v)>1:
            for vi in v:
                srcP = os.path.join(folderPath, vi+".jpg")
                dstP = os.path.join(DesFolder, k+"_"+vi+".jpg")
                shutil.copyfile(srcP,dstP)

Content Based Image Retrieval (CBIR)

July 18, 2011 Leave a comment
Some abstract notes for CBIR. As doing the project, actually more problems come from the pre-processing part.
Core Techniques:
1. Visual Signature (Sensory, Semantic)
2. Similarity Measurement
3. Classification & Clustering
4. Search Paradigms
Real world
1. User Intent(Browser, Surfer, Searcher)
2. Data Scope
3. Query Processing
4. Result Visualization
– Relevance-Ordered
– Time-Ordered
– Clustered
– Hierarchical
– Composite

Visual Similarity vs. Semantic Similarity
→ Application dependent

Domains for Visual Search:
– Narrow: Narrow image domains usually have limited variability  and better-defined visual characteristics.
– Broad  : tend to have high variability and unpredictability for the same underlying semantic concepts.

3 Types of Broad Image Search:
– search by association, where there is not clear intent at a picture, but instead the serch proceeds by iteratively refined browsing
– aimed search, where a specific picture is sought
– category search, where a single picture representative of a semantic class is sought
⇒ The overall goal is to bridge the semantic and sensorial gaps using the available visual features of images and relevant domain knowledge

In Sensorty property:
feature extraction geared at reducing the sensory gap due to the accidental distortions, cluster, occlusion, etc

– LUV color space – seem to coincide better with human vision than the basic RGB
– Texture: capture the granularity and repetitive patterns of surface

– Colorfulness:
Every color has two perceptual attributes relate to its chromaticness or colorfulness:
1. Saturation, defined as the colorfulness of an area judged in proportion to its brightness
2. Chroma, the colorfulness of an area judged as a proportion of the brightness of a similarity illuminated white or highly transmitting area.
Saturation * Illuminant

Chromaticness(colorfulness) is the attribute of a visual sensation according to which the perceived color of an area appears to be more or less chromatic.

Python for weka, Image Processing

July 18, 2011 Leave a comment

I am trying to use Java within Python. But it seems that it is still not fully ‘done’ for integrate the power of Python and Java. Jython is one option, but it is not including the numpy and scipy.  Here is the link for some examples for using weka from Jython.

Also, sadly, there are not too many packages for image processing (Image, Mahotas, OpenCV-python wrapper). In terms of UI, wxpython is good choice, but to make things with animation effect, you have to switch to python game, etc. And many things require dependent packages, which is not convenient. Especially, to create a cover flow effect is not so simple.  Below are some cover flow demo that I found interesing:

Anyway, I still love python very much, which is so clear and much easier to express your idea.

 

# Install the pygame for linux:
http://www.pygame.org/wiki/CompileUbuntu?parent=Compilation
#install dependencies
sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev

svn co svn://seul.org/svn/pygame/trunk pygame

cd pygame
python setup.py build
sudo python setup.py install

 

Categories: Image Processing, Python

Summer Reading Wish List

May 20, 2011 Leave a comment

I have been expecting the reading group for a long time, and now come to realize, but unfortunately, currently out of University this summer. Anyway, it’s good to follow and make some discussions remotely.
Below is the tentative list by Prof. Bouman. I was always impressed by his passion, and his lectures are just GREAT! I still remember it vividly when I was taking one of his course on image processing.

[Log]:
-05/20- The list is not complete yet. I will update it and put corresponding links for each sub-topics.

[List]:
# Compressed Sensing
1. D. Donoho – Compressed Sensing

2. Wright et. Al – Robust Face Recognition via Sparse Representation
# Image Processing and Vision
1. Peyman Milanfar – A Tour of Modern Image Filtering ( with the earlier version as ‘A Tour of Modern Image Processing’)
It’s video-lecture.
2. Zyg Pizlo – Binocular vision paper
3. Segmentation, state-of-the-art

# High-Dimensional/Sparse Methods
1. Al. Hero et. Al – Large Scale Correlation Screening

# Dictionary Learning
2. Elad – K-SVD paper
3. Some other dictionary learning paper – possibilities
a. Wolberg
b. Shapiro
4. Moody – Classification of Transient signals

# Physics Modeling and Inversion
1. Nicholas Zabaras – manifold learning
2. Marc De Graef – vector tomography for microscopy

# Dirichlet Processes
1. Michael Jordan’s Tutorial
Graphical Models
2. Need to find papers – two major topics:
a. Belief propagation Tutorial
b. Uses of graphical models

# Johnson Lindenstrauss Lemma
1. Identify good tutorial

# Regularized Discriminant Analysis
1. Friedman – Regularized Discriminant Analysis
2. Jiang – Eigenfeature Regularization and Extraction in Face Recognition
3. Hasib – Sparse Fisher’s Linear Discriminant Analysis