RGB colored image segmentation

6 ビュー (過去 30 日間)
S C.Carl
S C.Carl 2016 年 1 月 24 日
コメント済み: Image Analyst 2016 年 1 月 24 日
Hi all,
I have an RGB colored histology slide. I am getting blue and green components in this image by,
imgG=IMG(:,:,2); imgB=IMG(:,:,3);
However, l don't want to see these imgG and imgB images as grayscale. I want to see these parts with their original color and texture that are in the IMG. How to do this?
My second question is: l want to have information about vector flow of the segmented parts to see directions. Could you please help me how to do this? Thanks

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 1 月 24 日
imgG = IMG; imgG(:,:,[1 3]) = 0;
imgB = IMG; imgB(:,:,[1 2]) = 0;
imgR = IMG; imgR(:,:,[2 3]) = 0;
Second question
You can calculate gradient information. Once you have it, you can quiver() to display it.

Image Analyst
Image Analyst 2016 年 1 月 24 日
You need to make up color maps, such as
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
%===============================================================================
% Read in a demo image.
folder = fileparts(which('peppers.png')); % Determine where demo folder is (works with all versions).
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Display the image.
subplot(2, 2, 1);
imshow(rgbImage, []);
axis on;
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Display the image.
hImage = subplot(2, 2, 2);
imshow(redChannel, []);
axis on;
title('Red Channel Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Create a colormap for red.
axes(hImage);
z = zeros(256,1);
ramp = linspace(0, 1, 256)';
cmap = [ramp, z, z];
colormap(hImage, cmap);
colorbar;
% Display the image.
hImage = subplot(2, 2, 3);
imshow(greenChannel, []);
axis on;
title('Green Channel Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Create a colormap for red.
z = zeros(256,1);
ramp = linspace(0, 1, 256)';
cmap = [z, ramp, z];
colormap(hImage, cmap);
colorbar;
% Display the image.
hImage = subplot(2, 2, 4);
imshow(blueChannel, []);
axis on;
title('Blue Channel Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Create a colormap for red.
z = zeros(256,1);
ramp = linspace(0, 1, 256)';
cmap = [z, z, ramp];
colormap(hImage, cmap);
colorbar;
  1 件のコメント
Image Analyst
Image Analyst 2016 年 1 月 24 日
For the second question about optical flow, you'll have to use the optical flow capability in the Computer Vision System Toolbox.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by