<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/281734</link>
    <title>MATLAB Central Newsreader - getting subimages</title>
    <description>Feed for thread: getting subimages</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2013 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.co.uk/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 10 May 2010 13:09:21 +0000</pubDate>
      <title>getting subimages</title>
      <link>http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/281734#743767</link>
      <author>subrajeet Mohapatra</author>
      <description>I want to create subimages from a single image which contains many WBC cells. I am using regionprop and bounding box  it is creating many unwanted subimages also. I have tried convexhull also same problem persists. Any way to reduce small unwanted subimages.&lt;br&gt;
&lt;br&gt;
the below link contains the image&lt;br&gt;
&lt;a href="http://www.healthsystem.virginia.edu/internet/hematology/images/Acute-lymphoblastic-leukemia-L1-subtype-100x-website.jpg"&gt;http://www.healthsystem.virginia.edu/internet/hematology/images/Acute-lymphoblastic-leukemia-L1-subtype-100x-website.jpg&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 10 May 2010 16:46:39 +0000</pubDate>
      <title>Re: getting subimages</title>
      <link>http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/281734#743847</link>
      <author>Jan</author>
      <description>On 5/10/2010 3:09 PM, subrajeet Mohapatra wrote:&lt;br&gt;
&amp;gt; I want to create subimages from a single image which contains many WBC&lt;br&gt;
&amp;gt; cells. I am using regionprop and bounding box it is creating many&lt;br&gt;
&amp;gt; unwanted subimages also. I have tried convexhull also same problem&lt;br&gt;
&amp;gt; persists. Any way to reduce small unwanted subimages.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; the below link contains the image&lt;br&gt;
&amp;gt; &lt;a href="http://www.healthsystem.virginia.edu/internet/hematology/images/Acute-lymphoblastic-leukemia-L1-subtype-100x-website.jpg"&gt;http://www.healthsystem.virginia.edu/internet/hematology/images/Acute-lymphoblastic-leukemia-L1-subtype-100x-website.jpg&lt;/a&gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
you could get rid of small areas by smoothing the image before. however &lt;br&gt;
than also adjacent cells would be melted and could be differentiated &lt;br&gt;
enough. a mixture of smoothing, adaptive thresholds (including the &lt;br&gt;
laplacian, etc. ) and a threshold on number of pixels in resulting area &lt;br&gt;
can help. however under different conditions the parameters of the &lt;br&gt;
algorithm like the thresholds will have to be adapted.&lt;br&gt;
&lt;br&gt;
I crafted an example for you, that might act as an inspiration. However &lt;br&gt;
this is a whole search area with many possible approaches. This is only &lt;br&gt;
the easiest one.&lt;br&gt;
&lt;br&gt;
Jan&lt;br&gt;
&lt;br&gt;
function [subs] = SimpleRegionSelection()&lt;br&gt;
% Divides images of many cells in single images of cells using some simple&lt;br&gt;
% smoothing and threshold criteria. Works only on good-enough pictures and&lt;br&gt;
% may require tweaking.&lt;br&gt;
%&lt;br&gt;
% Jan Keller (jkeller1@gwdg.de)&lt;br&gt;
&lt;br&gt;
[image, colmap] = &lt;br&gt;
imread('Acute-lymphoblastic-leukemia-L1-subtype-100x-website.jpg'); % &lt;br&gt;
three frames (r,g,b) I believe&lt;br&gt;
&lt;br&gt;
% parameters&lt;br&gt;
smoothing_size = 10; % smoothing gaussian diameter in pixel&lt;br&gt;
threshold = .18; % intensity treshold relative to maximum&lt;br&gt;
numpixel_threshold = 5000; % number of pixel threshold in each area&lt;br&gt;
&lt;br&gt;
img = double(image);&lt;br&gt;
img = sqrt(img); % this is a trick to reduce the influence of image &lt;br&gt;
noise on the whole algorithm&lt;br&gt;
&lt;br&gt;
% first step some smoothing (3 pixels wide)&lt;br&gt;
l = round(2 * smoothing_size);&lt;br&gt;
[x, y] = ndgrid(-l:l, -l:l);&lt;br&gt;
smoothing_kernel = power(2., -(x.^2+y.^2) / (smoothing_size/2)^2);&lt;br&gt;
&lt;br&gt;
smoothed = zeros(size(img));&lt;br&gt;
for ki = 1 : size(img, 3)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;smoothed(:, :, ki) = imfilter(img(:, :, ki), smoothing_kernel, 'same');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% add all three color channels up and normalize and make negative because&lt;br&gt;
% original image is white outside of cells&lt;br&gt;
smoothed = sum(smoothed, 3);&lt;br&gt;
smoothed = 1. - smoothed ./ max(smoothed(:));&lt;br&gt;
&lt;br&gt;
% thresholding and get regions&lt;br&gt;
bw = smoothed &amp;gt; threshold;&lt;br&gt;
[label, n] = bwlabel(bw);&lt;br&gt;
&lt;br&gt;
% separate to subs&lt;br&gt;
subs = {};&lt;br&gt;
for ki = 2 : n % ignoring the first, its the background&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% get values of coordinates in regions&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;maskpos = find(label == ki);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[x, y] = ind2sub(size(label), maskpos);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% obtain bounding box with some border&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;border = 5;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmin = max(min(x) - border, 1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmax = min(max(x) + border, size(label, 1));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ymin = max(min(y) - border, 1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ymax = min(max(y) + border, size(label, 2));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;chunk = image(xmin:xmax,ymin:ymax,:);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;numpixel = size(chunk, 1) * size(chunk, 2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fprintf('%d\n', numpixel);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if numpixel &amp;gt; numpixel_threshold&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% write to cell array&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subs = [subs, {}];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% this is just for visualisztion&lt;br&gt;
figure;&lt;br&gt;
imagesc(label);&lt;br&gt;
title('image mask');&lt;br&gt;
for ki = 1 : length(subs)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;figure;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imagesc(subs{ki});&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;colormap(colmap);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s = sprintf('subimage %d', ki);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;title(s);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Mon, 10 May 2010 17:39:01 +0000</pubDate>
      <title>Re: getting subimages</title>
      <link>http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/281734#743858</link>
      <author>ImageAnalyst</author>
      <description>On May 10, 9:09 am, "subrajeet Mohapatra" &amp;lt;subraje...@gmail.com&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; I want to create subimages from a single image which contains many WBC cells. I am using regionprop and bounding box  it is creating many unwanted subimages also. I have tried convexhull also same problem persists. Any way to reduce small unwanted subimages.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; the below link contains the image&lt;a href="http://www.healthsystem.virginia.edu/internet/hematology/images/Acute"&gt;http://www.healthsystem.virginia.edu/internet/hematology/images/Acute&lt;/a&gt;...&lt;br&gt;
&lt;br&gt;
----------------------------------------&lt;br&gt;
You could use ismember after regionprops if you want to filter on&lt;br&gt;
size, or any combination of other measurements (such as color, shape,&lt;br&gt;
etc.).  See this image segmentation demo for an example:&lt;br&gt;
&lt;a href="http://www.mathworks.com/matlabcentral/fileexchange/25157"&gt;http://www.mathworks.com/matlabcentral/fileexchange/25157&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Or you could use bwareaopen on the binary image (before labeling and&lt;br&gt;
regionprops) if you want to filter on just area alone.</description>
    </item>
    <item>
      <pubDate>Tue, 11 May 2010 08:07:25 +0000</pubDate>
      <title>Re: getting subimages</title>
      <link>http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/281734#744028</link>
      <author>Jan</author>
      <description>actually some simple watershed segmentation algorithm could probably &lt;br&gt;
also do the trick &lt;br&gt;
&lt;a href="http://www.mathworks.com/company/newsletters/news_notes/win02/watershed.html"&gt;http://www.mathworks.com/company/newsletters/news_notes/win02/watershed.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
or this &lt;a href="http://www.diplib.org/"&gt;http://www.diplib.org/&lt;/a&gt; is also a nice library and does many of &lt;br&gt;
these things automatically however I have no example for it...&lt;br&gt;
&lt;br&gt;
regards jan</description>
    </item>
  </channel>
</rss>
