Color image--image cutting color space cutting

Source: Internet
Author: User

Know the last day of dip
Reprint please indicate the source of the article:Http://blog.csdn.net/tonyshengtan , out of respect for the work of the author of the article, reproduced please indicate the source. Article code is hosted, Welcome to co-development:Https://github.com/Tony-Tan/DIPpro

The opening crap.

The last article in this series. Perhaps the article will be written in the other series. I want to put the wavelet also in this series, but feel recently write wavelet a little difficult, here learning environment is not good, want to write some fun, for example pattern recognition. Image features dot What, I hope you continue to pay attention.

Algorithm principle

Simple cutting of multi-channel images. Can be given a threshold vector, and then given a range, can be three-dimensional spherical, or cube, this depends on the detailed design, for example, to give a simple example, given the RGB center threshold value is t ?  ( R 0 , G 0 , B 0 ) , the threshold value is 100. So for pixel points ( x , y ) Span style= "Display:inline-block; width:0px; Height:2.56em; " > Color vector at the i ?  ( r x y , g x y , b x y )
So just to meet

|t ?  i ?  |< -

Points to meet the requirements for the target point. Otherwise, the background point.


The same algorithm applies to other color spaces. However, it is very flexible to design according to the detailed situation.

Code
Double chanel3distance (RGB Point1,rgb point2) {return sqrt (point1. C1-point2. C1) * (point1. C1-point2. C1) + (point1. C2-point2. C2) * (point1. C2-point2. C2) + (point1. C3-point2. C3) * (point1. C3-point2. C3));}void Segmentrgb (rgb* src,rgb *dst,int width,int Height,rgb * color_center,double threshold) {double distance=0.0;for (int i=0; i<width*height;i++) {Distance=chanel3distance (Src[i], *color_center);if (distance<=threshold) {Dst[i]. C1=src[i]. C1;Dst[i]. C2=src[i]. C2;Dst[i]. C3=src[i]. C3;}else{Dst[i]. C1=0.;Dst[i]. C2=0.;Dst[i]. C3=0.;}    }}
Results analysis

The following simple cuts and smoothing are then combined.


Original:

Cut (use simple RGB model, skin color cut point simple selection, so the effect is not very good):

Merge after smoothing

Original:

Cutting results:

Summarize

It took 70 days to simply introduce the basic knowledge of image processing. Specific applications because they do not have the industry versatility. Therefore will have the choice to carry on the study, thanks oneself all the way persisted for a few months, thanks everybody has been supporting, hoped everybody's technical progress.
The end of this series.


Technology. Cond.

。。

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Color image--image cutting color space cutting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.