<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.hshl.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Image_Processing%3A_Data_based_segmentation</id>
	<title>Image Processing: Data based segmentation - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hshl.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Image_Processing%3A_Data_based_segmentation"/>
	<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=Image_Processing:_Data_based_segmentation&amp;action=history"/>
	<updated>2026-04-19T19:57:46Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in HSHL Mechatronik</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.hshl.de/wiki/index.php?title=Image_Processing:_Data_based_segmentation&amp;diff=147080&amp;oldid=prev</id>
		<title>Ajay.paul@stud.hshl.de am 5. März 2026 um 13:22 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=Image_Processing:_Data_based_segmentation&amp;diff=147080&amp;oldid=prev"/>
		<updated>2026-03-05T13:22:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 5. März 2026, 13:22 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l100&quot;&gt;Zeile 100:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 100:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;imsegkmeans&amp;lt;/code&amp;gt;: A specialized function for image segmentation using K-Means (optimized for image data structures).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;imsegkmeans&amp;lt;/code&amp;gt;: A specialized function for image segmentation using K-Means (optimized for image data structures).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;imagesc&amp;lt;/code&amp;gt;: Displays data as an image using the full range of the current colormap (useful for viewing label matrices).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;imagesc&amp;lt;/code&amp;gt;: Displays data as an image using the full range of the current colormap (useful for viewing label matrices).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;SVN Repository:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;https://svn.hshl.de/svn/MATLAB_Vorkurs/trunk/Signalverarbeitung_mit_Kuenstlicher_Intelligenz/Image%20Processing%20with%20MATLAB%20and%20AI/image_processing_matlab/4_Data_Segmenation/&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ajay.paul@stud.hshl.de</name></author>
	</entry>
	<entry>
		<id>https://wiki.hshl.de/wiki/index.php?title=Image_Processing:_Data_based_segmentation&amp;diff=146808&amp;oldid=prev</id>
		<title>Ajay.paul@stud.hshl.de: Die Seite wurde neu angelegt: „= Data-Based Segmentation: K-Means Clustering =  &#039;&#039;&#039;Data-Based Segmentation&#039;&#039;&#039; involves partitioning an image into distinct regions based purely on the statistical properties of the pixel data (such as color or intensity), without using a specific geometric model (like circles or lines).  This article explores how to segment a microscopic tissue image using the **K-Means Clustering** algorithm in the L*a*b* color space.  __TOC__  == Theoretical Background…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.hshl.de/wiki/index.php?title=Image_Processing:_Data_based_segmentation&amp;diff=146808&amp;oldid=prev"/>
		<updated>2026-02-04T11:49:44Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „= Data-Based Segmentation: K-Means Clustering =  &amp;#039;&amp;#039;&amp;#039;Data-Based Segmentation&amp;#039;&amp;#039;&amp;#039; involves partitioning an image into distinct regions based purely on the statistical properties of the pixel data (such as color or intensity), without using a specific geometric model (like circles or lines).  This article explores how to segment a microscopic tissue image using the **K-Means Clustering** algorithm in the L*a*b* color space.  __TOC__  == Theoretical Background…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Data-Based Segmentation: K-Means Clustering =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data-Based Segmentation&amp;#039;&amp;#039;&amp;#039; involves partitioning an image into distinct regions based purely on the statistical properties of the pixel data (such as color or intensity), without using a specific geometric model (like circles or lines).&lt;br /&gt;
&lt;br /&gt;
This article explores how to segment a microscopic tissue image using the **K-Means Clustering** algorithm in the L*a*b* color space.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Theoretical Background ==&lt;br /&gt;
&lt;br /&gt;
=== K-Means Clustering ===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;K-Means&amp;#039;&amp;#039;&amp;#039; is an unsupervised machine learning algorithm used to partition data into &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; distinct clusters.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Initialization:&amp;#039;&amp;#039;&amp;#039; Select &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; random points as initial cluster centroids.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Assignment:&amp;#039;&amp;#039;&amp;#039; Assign every pixel in the image to the nearest centroid based on a distance metric (usually Euclidean distance).&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Update:&amp;#039;&amp;#039;&amp;#039; Recalculate the centroids by taking the mean of all pixels assigned to each cluster.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Repeat:&amp;#039;&amp;#039;&amp;#039; Iterate steps 2 and 3 until the centroids stabilize (convergence).&lt;br /&gt;
&lt;br /&gt;
=== Color Space Transformation ===&lt;br /&gt;
Standard RGB images mix color and lighting information, which can confuse segmentation algorithms.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;RGB (Red, Green, Blue):&amp;#039;&amp;#039;&amp;#039; Not ideal for segmentation because color distance in RGB does not match human perception.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;L*a*b* (Lightness, a*, b*):&amp;#039;&amp;#039;&amp;#039; A perceptually uniform color space.&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;L*:&amp;#039;&amp;#039;&amp;#039; Lightness (0 = Black, 100 = White).&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;a*:&amp;#039;&amp;#039;&amp;#039; Green to Red component.&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;b*:&amp;#039;&amp;#039;&amp;#039; Blue to Yellow component.&lt;br /&gt;
By ignoring the &amp;#039;&amp;#039;&amp;#039;L*&amp;#039;&amp;#039;&amp;#039; channel and clustering only on &amp;#039;&amp;#039;&amp;#039;a*&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;b*&amp;#039;&amp;#039;&amp;#039;, we segment based purely on color, making the algorithm robust to lighting variations.&lt;br /&gt;
&lt;br /&gt;
== MATLAB Implementation ==&lt;br /&gt;
&lt;br /&gt;
The following MATLAB script demonstrates loading an image, converting color spaces, applying K-Means, and visualizing the result.&lt;br /&gt;
&lt;br /&gt;
=== Code Logic ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% Data-Based Segmentation&lt;br /&gt;
% Algorithm: K-Means Clustering (imsegkmeans)&lt;br /&gt;
clc; clear; close all;&lt;br /&gt;
&lt;br /&gt;
% 1. Load the Image&lt;br /&gt;
% &amp;#039;hestain.png&amp;#039; is a standard MATLAB demo image of H&amp;amp;E stained tissue&lt;br /&gt;
I = imread(&amp;#039;hestain.png&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
% 2. Convert to L*a*b* (Feature Extraction)&lt;br /&gt;
% We transform RGB to L*a*b* to isolate color information.&lt;br /&gt;
lab_I = rgb2lab(I);&lt;br /&gt;
&lt;br /&gt;
% Extract the a* and b* channels. &lt;br /&gt;
% These contain the color info (Red/Green/Blue/Yellow balance).&lt;br /&gt;
ab = lab_I(:,:,2:3);&lt;br /&gt;
&lt;br /&gt;
% Convert to single precision for the K-Means algorithm calculation&lt;br /&gt;
ab = im2single(ab);&lt;br /&gt;
&lt;br /&gt;
% 3. Run K-Means&lt;br /&gt;
% We choose k=3 because H&amp;amp;E stained images typically contain:&lt;br /&gt;
% 1. Purple (Nuclei)&lt;br /&gt;
% 2. Pink (Cytoplasm/Tissue)&lt;br /&gt;
% 3. White (Background)&lt;br /&gt;
k = 3; &lt;br /&gt;
pixel_labels = imsegkmeans(ab, k, &amp;#039;NumAttempts&amp;#039;, 3);&lt;br /&gt;
&lt;br /&gt;
% 4. Visualization&lt;br /&gt;
figure(&amp;#039;Name&amp;#039;, &amp;#039;Task 4: Segmentation Results&amp;#039;, ...&lt;br /&gt;
       &amp;#039;NumberTitle&amp;#039;, &amp;#039;off&amp;#039;, ...&lt;br /&gt;
       &amp;#039;Position&amp;#039;, [100, 100, 1000, 500]);&lt;br /&gt;
&lt;br /&gt;
% Show Original&lt;br /&gt;
subplot(1, 2, 1);&lt;br /&gt;
imshow(I);&lt;br /&gt;
title(&amp;#039;Original Image&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
% Show Segmentation Label Matrix&lt;br /&gt;
subplot(1, 2, 2);&lt;br /&gt;
imagesc(pixel_labels);&lt;br /&gt;
axis image;&lt;br /&gt;
colormap(gca, jet); % &amp;#039;jet&amp;#039; gives distinct colors for 1, 2, and 3&lt;br /&gt;
colorbar;&lt;br /&gt;
title([&amp;#039;K-Means Clusters (k=&amp;#039;, num2str(k), &amp;#039;)&amp;#039;]);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of Results ==&lt;br /&gt;
&lt;br /&gt;
The result, stored in &amp;lt;code&amp;gt;pixel_labels&amp;lt;/code&amp;gt;, is a matrix of the same size as the image where every value is 1, 2, or 3.&lt;br /&gt;
&lt;br /&gt;
[[Datei:Segmentation Results.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Interpretation ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cluster 1:&amp;#039;&amp;#039;&amp;#039; Typically corresponds to the white background (low a*, low b*).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cluster 2:&amp;#039;&amp;#039;&amp;#039; Typically corresponds to the pink connective tissue (medium a*).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cluster 3:&amp;#039;&amp;#039;&amp;#039; Typically corresponds to the purple nuclei (high a*, low b*).&lt;br /&gt;
&lt;br /&gt;
Note: The specific label numbers (1, 2, 3) depend on random initialization and may swap between runs.&lt;br /&gt;
&lt;br /&gt;
=== Why use &amp;#039;NumAttempts&amp;#039;? ===&lt;br /&gt;
K-Means can get stuck in local minima depending on where the initial centroids are placed. By setting &amp;lt;code&amp;gt;&amp;#039;NumAttempts&amp;#039;, 3&amp;lt;/code&amp;gt;, MATLAB runs the algorithm 3 times with different random starting points and returns the result with the lowest total error summation.&lt;br /&gt;
&lt;br /&gt;
== Key MATLAB Functions ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;rgb2lab&amp;lt;/code&amp;gt;: Converts images from RGB to CIE L*a*b* color space.&lt;br /&gt;
* &amp;lt;code&amp;gt;imsegkmeans&amp;lt;/code&amp;gt;: A specialized function for image segmentation using K-Means (optimized for image data structures).&lt;br /&gt;
* &amp;lt;code&amp;gt;imagesc&amp;lt;/code&amp;gt;: Displays data as an image using the full range of the current colormap (useful for viewing label matrices).&lt;/div&gt;</summary>
		<author><name>Ajay.paul@stud.hshl.de</name></author>
	</entry>
</feed>