Hiii...
I want to divide a hue image into 10 sectors.for that first i multiplied obtained hue image by 360.how can i do this?? is there any function to divide hue image into sectors.
No products are associated with this question.
How about logical indexing? Multiplying by 360 is not necessary. Why do you think it is?
h1 = h(h < 0.1); h2 = h(h > 0.1 & h < 0.2); h3 = h(h > 0.2 & h < 0.3);
etc. up to h10. If you want an image instead of a list of values, then you'll have to do masking
h2 = h .* double(h > 0.1 & h < 0.2);
etc.
yes i want h1 through h10 to be 2D image..then what is the code in matlab??
See my code below. The B computed in each run of the loop are the h1, h2, ... images you need.
See my demo:
clc; % Clear the command window. close all; % Close all figures (except those of imtool.) imtool close all; % Close all imtool figures if you have the Image Processing Toolbox. 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 standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(3, 4, 1);
imshow(rgbImage, []);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
hsv = rgb2hsv(rgbImage);
hueImage = hsv(:,:,1);
numberOfHues = 10;
for hue = 1 : numberOfHues
% Get a binary image of where this hue is.
mask = hueImage > (hue-1)/numberOfHues & hueImage <= hue/numberOfHues;
% Extract it from the image
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
subplot(3, 4, hue+1);
imshow(maskedRgbImage);
caption = sprintf('Hue #%d Image', hue);
title(caption, 'FontSize', fontSize);
end
Ncolors = 10;
I = imread('peppers.png');
HSV = rgb2hsv(I);
H = HSV(:,: ,1);
Hnew = zeros(size(H)); delta = 1/Ncolors; for range = delta:delta:1 B = H >= range - delta & H < range; Hnew(B>0) = range - delta/2; end
HSV(:,:,1) = Hnew; subplot(1,2,1), imshow(I) subplot(1,2,2), imshow(hsv2rgb(HSVnew))
Thank you...I want to create a 306 degree hue circle in matlab and then I want to divide that hue circle into ten sectors..i tried to create but I dint get it...what is the code to create hue circle???
Image Analyst's demo of February 13th shows you one way to proceed.
0 Comments