How to use RGB transformation in to HSV and extract different layers and proccess it?

4 views (last 30 days)
My task will be to map the intensity from the RGB model to the HSV model, where I will perform filtering. Then map the resulting image back to the RGB model.
Any tips or recommendation where I have to start and where I have to be careful in doing it.
I have the jpeg image which is 612 × 408 ×3, first i need to normalize image in to interval from 0-1, then use transformation function whit following parameteres: vi = max(ri , gi , bi) ci = max(ri , gi , bi) − min(ri , gi , bi) li = vi − ci 2 hi = 60deg · ( gi−bi ci ), vi = ri 60deg · (2 + bi−ri ci ), vi = gi 60deg · (4 + ri−gi ci ), vi = bi 0, ci = 0. (redi, greeni, bluei).
In the 3. part in need fold model in to proper fit:
The obtained values ​​of 'hi' , 'si' , 'vi' , which make up the HSV record (hue, saturation and value), fold in an array of the same size as the input RGB image so that each image element will have (xi , yi) values ​​(hi , si , vi).
Thank you.

Accepted Answer

Image Analyst
Image Analyst on 15 Aug 2022
Use the built-in functions rgb2hsv and hsv2rgb
hsvImage = rgb2hsv(rgbImage);
[hi, si, vi] = imsplit(hsvImage);
% Then do filtering of any of them.
% Then rebuild a filtered RGB image
hsvImage = cat(3, hi, si, vi);
filteredRGBImage = hsv2rgb(hsvImage);
  6 Comments
Image Analyst
Image Analyst on 18 Aug 2022
I'd use imsplit and cat and do the whole thing vectorized, using the whole arrays rather than a nessted for loop. And of course I'd put in tons more comments like all professional programmers should do.
I do give internal short courses occasionally as part of my job for my employer but that's not my main job.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!