Dark image separation

So I have an image. I take it into HSV format and v has its intensity values.

now the intensity values of v vary from 0 to 1 (Black to White)

I want to divide v into 3 parts:

1] v1= with intensity values 0<v<0.3

2] v2= with intensity values 0.3<v<0.75

3] v3= with intensity values 0.75<v<0.1

How do I do this?

All you need to do is masking on your v we remember and image is a [rows,cols,layers] matrix, where the layers are Hue=1,saturation=2,intensity value=3

We then create a mask (array of 0s and 1s). For example your first range would be

v1 = (hsv_im(:,:,v_idx) <0.3);


we are taking the all rows, all columns, of layer v, and if the value is <0.3 make it 1, otherwise make it 0. Now to see only those pixels we can multiply the original value array by our mask.

hsv_im(:,:,v_idx) = v0.*v1_mask;


As you recall any value >0.3 was 0 in our mask, so all the other areas will be blacked out.

here is a full example

im = imread('flower.jpg');
hsv_im = rgb2hsv(im);
v_idx =3;

v0 = (hsv_im(:,:,v_idx));    %the original
v2_mask = (hsv_im(:,:,v_idx) <=0.3 & hsv_im(:,:,v_idx) <0.75);

%plots the images
figure(1);
subplot(2,2,1);imshow(hsv2rgb(hsv_im));title('original')

subplot(2,2,2);imshow(hsv2rgb(hsv_im));title('0.00< v<0.30')