PRODUCTS
Products Overview
Mathematica
Mathematica Student Edition
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
Wolfram
SystemModeler
Wolfram
Finance Platform
Mathematica
Add-Ons
Wolfram|Alpha Products
SOLUTIONS
Solutions Overview
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Materials Science
Mechanical Engineering
Operations Research
Optics
Petroleum Engineering
Biotechnology & Medicine
Bioinformatics
Medical Imaging
Finance, Statistics & Business Analysis
Actuarial Sciences
Data Analysis & Mining
Econometrics
Economics
Financial Engineering & Mathematics
Financial Risk Management
Statistics
Software Engineering & Content Delivery
Authoring & Publishing
Interface Development
Software Engineering
Web Development
Science
Astronomy
Biological Sciences
Chemistry
Environmental Sciences
Geosciences
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
Education
STEM Education Initiative
Higher Education
Community & Technical College Education
Primary & Secondary Education
Students
Technology
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
PURCHASE
Online Store
Other Ways to Buy
Volume & Site Licensing
Contact Sales
Software
Service
Upgrades
Training
Books
Merchandise
SUPPORT
Support Overview
Mathematica
Documentation
Knowledge Base
Learning Center
Technical Services
Community & Forums
Training
Does My Site Have a License?
Wolfram User Portal
COMPANY
About Wolfram Research
News
Events
Wolfram Blog
Partnerships
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
All Sites
Wolfram|Alpha
Demonstrations Project
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Media
Wolfram
Tones
Wolfram Science
Stephen Wolfram
DOCUMENTATION CENTER SEARCH
User's Guide
Image Segmentation
7.6 Example: Color Image Segmentation
In this example we use clustering to segment an example image according to color features. Subsequently we show examples of color-selective masking operations. This is accomplished by clustering the pixel values in the 3D RGB color space. The determination of the number of clusters comes from a visual examination of the example image. Iterative refinement of the clustering outcome is possible based on a global classification measure. Alternatively, the classification result may be refined in a postprocessing step, by removing outliers from each of the clusters and appropriately labeling them as belonging to none of the selected color classes.
In[1]:=
This reads the
beans
image and extracts a subregion for further processing.
In[2]:=
Here we cluster the color pixel values into three groupings according to their RGB values. The clusters define background, green bean, and red bean pixels. The initial seed values are estimates of typical color values in these three regions.
In[3]:=
Here we verify the resulting clustering by listing the cluster centers.
In[4]:=
Out[4]=
This shows the number of pixels in each of the color clusters.
In[5]:=
Out[5]=
This shows a scatter diagram of the cluster assignment of all the image pixels.
In[6]:=
Out[6]=
Given these classification results, we can now proceed with selective image operations. Here we find the positions of all the red pixels in the example image.
In[7]:=
Here we flood the region occupied by red beans with a uniform red color.
In[8]:=
This shows the result.
In[9]:=
Out[9]=
Here we mask all the nonred pixels, which includes the background and green bean pixels, with a uniform gray value. First we find the positions of all the pixels that belong to this category.
In[10]:=
This replaces all affected pixels with a uniform gray value.
In[11]:=
This shows the result.
In[12]:=
Out[12]=
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.