Prev: RC-Element
Next: FFT processing
From: shilpa khinvasara on 22 Jul 2010 02:35 sir, u already know that i am doing quantization of image into 18,3,3 bis with the following code now how do i count the pixels in each bin and plot its histogram i have corrected the code as per ur suggestion clc; clear all; close all; % Open a standard MATLAB demo image. rgbImage = imread('test.jpg'); rgbImage=im2double(rgbImage); % Display the original image. figure; subplot(2, 4, 1); imshow(rgbImage, []); title('Original RGB image'); % Convert to HSV color space hsv = rgb2hsv(rgbImage); % Extract out the individual channels. h = hsv(:,:,1); s = hsv(:,:,2); v = hsv(:,:,3); % Display the individual channels. subplot(2, 4, 2); imshow(h, []); title('Hue Image'); subplot(2, 4, 3); imshow(s, []); title('Saturation Image'); subplot(2, 4, 4); imshow(v, []); title('Value Image'); % Take histograms [hCount, hValues] = hist(h(:), 18); [sCount, sValues] = hist(s(:), 3); [vCount, vValues] = hist(v(:), 3); % Plot histograms. subplot(2, 4, 5); bar(hValues, hCount); title('Hue Histogram'); subplot(2, 4, 6); bar(sValues, sCount); title('Saturation Histogram'); subplot(2, 4, 7); bar(vValues, vCount); title('Value Histogram'); h=h*360; [M,N,O]=size(hsv); H=floor(h * (1-eps) / 20); V = zeros(M,N); vplaces = v > 0.25; V(vplaces & s <= 0.2) = 3; V(vplaces & s <= 0.126) = 2; V(vplaces & s <= 0.67) = 1; S=zeros(size(hsv,1),size(hsv,2)); for i=1:M for j=1:N if s(i,j)>0.2&&s(i,j)<=1&&v(i,j)>0.25&&v(i,j)<=1 q(i,j)=9*H(i,j)+3*S(i,j)+V(i,j)+4; end end end pls let me know the corrections. thanks a lot lot
From: Walter Roberson on 22 Jul 2010 03:01 shilpa khinvasara wrote: > sir, > u already know that i am doing quantization of image into 18,3,3 bis > with the following code > now how do i count the pixels in each bin and plot its histogram I already gave you the code needed to count the pixels in each bin and plot its histogram. It was a single call to hist . > S=zeros(size(hsv,1),size(hsv,2)); You failed to populate the S array before you use it in the loop that follows. > for i=1:M > for j=1:N > if s(i,j)>0.2&&s(i,j)<=1&&v(i,j)>0.25&&v(i,j)<=1 > q(i,j)=9*H(i,j)+3*S(i,j)+V(i,j)+4; > end > end > end You also do not pre-allocate the "q" array, and you do not have any indication of what that "q" array should contain for locations at which the "if" statement does not hold true. I see no reason why you would want to use a nested "for" loop to build the "q" array values. The technique used to construct "vplaces" can be used here to select the locations of interest and calculate your q values for those locations in one or two fully vectorized commands.
From: kaushalk on 22 Jul 2010 04:46 thanx a lot but still i am unable to understand that how to count pixels in each of quantzed image and plot its histogram
|
Pages: 1 Prev: RC-Element Next: FFT processing |