I want to divide the 360 degree hue circle into 10 equal sector

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.

Réponses (2)

Image Analyst
Image Analyst le 17 Nov 2012
Modifié(e) : Image Analyst le 17 Nov 2012
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.

11 commentaires

thank you .......... but, how to do masking in this ten sectors.... i mean, the hue channel of the obtained image is traversed with a mask of 3x3. the 3x3 region is considered to be a valid corner if there are at least two values registered from two non-adjacent sectors.....i dont know how to implement this in matlab.....plz any one help me....
I have no idea whatsoever what that means.
Before you have said ,to get an image we have to do masking. How to do masking in a 3x3 region.
In another Question, we asked you to explain what you meant about non-adjacent sectors, but my recollection is that you did not respond with something we could understand.
On the other hand, in the above when IA referred to "masking", he meant "logical indexing in order to select which elements were to be affected."
for dividing a single hue image into ten sectors, this code is used
h1 = h(h < 0.1); h2 = h(h > 0.1 & h < 0.2); h3 = h(h > 0.2 & h < 0.3); upto h10
then how to combine all this ten sectors into single hue image in matlab???
Thanks in advance
Image Analyst
Image Analyst le 13 Fév 2013
Modifié(e) : Image Analyst le 13 Fév 2013
You can't get the original hue image back because when you did the logical operations, you end up with 1D vectors and all spatial information is lost. Your h1 through h10 are 1D vectors. Do you need the h1 through h10 to be 2D images? Because that would require different formulas.
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
How about if want to use grayscale image?
That would be a totally different question. TOTALLY different. You can't even adapt the code above at all.
You'd have to create sectors with the FAQ http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_arc.3F and then use poly2mask() to get a masked image, if that's what you want.

Connectez-vous pour commenter.

Thorsten
Thorsten le 12 Fév 2013
Modifié(e) : Thorsten le 12 Fév 2013
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))

2 commentaires

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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Display Image dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by