Search
Topics:
Homework HW01 has two sub-tasks, follow the emphasized links to get to the detailed description.
Upload your report in PDF format to BRUTE to the assignment L03-Matlab:Statistics. Please name the PDF file as hw01_<your_fel_id>.pdf. Include the MATLAB code snippets in the report or upload them separately.
L03-Matlab:Statistics
hw01_<your_fel_id>.pdf
Please make yourself familiar with MATLAB commands, use one of the available tutorials. You can also work with Python, consider using the packages scipy and matplotlib.
Homework tasks
Use appropriate spacing of the grid to get a nicely-looking plot, like in the example below:
Hints To add multiple plots to a single figure, use hold on. To then have legend for each of the single plots, get the handle for each(the return values ps and po) and specify the legend manually, as shown in the following snippet:
hold on
ps
po
figure; ps = scatter(xc, Y, 'b+'); hold on; po = plot(xc, A * x, 'b'); legend([ps, po], {'Noisy data','Original'});
Segmentation is the task of describing image areas by some context information, like finding cells in microscopy images. We want to construct an automated detection procedure. A cell is typically a roundish dark object, so we first need to separate cell-like pixels from background and other structures by thresholding with a suitable threshold level. After reading (imopen) and converting to grayscale image rgb2gray,
level
I = imread('5830.png'); Ig = rgb2gray(I); figure; imshow(I,[],'InitialMagnification','fit');
level = graythresh(I_gray); Ibw = im2bw(I_gray, level);
[pixelCount grayLevels] = imhist(I_gray); bar(pixelCount);
We then search isolated (connected) areas in the binarized image and use regionprops to retrieve properties of each region:
[B, L] = bwboundaries(Ibw, 'noholes'); stats = regionprops('table',L,'Area');
Area
Eccentricity
Solidity
imshow(label2rgb(L, @jet, [.5 .5 .5]))
% Watershed - first compute distances for each pixel to the boundary % but since bwdist computes distances to non-zero pixels, we need to % logicaly revert the segmentation (~Ibw) D = bwdist(~Ibw); % If the watershed produces too many splits, try to smooth the distance image D = imgaussfilt(-D, 1.5); % Set distance to Infinity for places, where our binary image is zero D(~Ibw) = Inf; % Get labels by watershed transform Lw = watershed(D, 8); Lw(~Ibw) = 0;
Finally, we want to filter the detected regions by the retrieved measures and for the correct ones plot their boundary in the original input image I
I
imshow(I); hold on for k = 1:length(B) if stats.Area(k) > ?? boundary = B{k}; plot(boundary(:,2), boundary(:,1), 'y', 'LineWidth', 2) end end
Task Find suitable criterion on region properties (like Area, Solidity etc.) to select cell-regions for each of the following data: 5140.png 5830.png histopato1.png histopato2.png
help, rand, meshgrid, surf, imread, rgb2gray, imshow, lookfor, edit, path, addpath, format, end, reshape, inf, nan, isempty, floor, ceil, round, abs, sign, ops, length, linspace, sort, det, rank, load, save, fprintf, axis, title, contour, mesh, surf, colormap, print, for, if, while, function
Plot the resulting segmentation as boundary contour over the original image, like shown in the last picture.
MATLAB Help
Python Help