Select ROI (Region Of Interest) from a video, and extracting rgb values

30 ビュー (過去 30 日間)
Shu-An Hsieh
Shu-An Hsieh 2022 年 5 月 17 日
コメント済み: Shu-An Hsieh 2022 年 9 月 29 日
Hi,
I am wondering if there is a way that I can analyze a region of interest in a video and extract the rgb value in that video? Thank you.

採用された回答

Nihal Reddy
Nihal Reddy 2022 年 6 月 3 日
I understand you want to first select the Region of Interest(ROI) from a video and then extract RGB values from the selected ROI.
The first step would be to split the videos into frames and then select the region of interest using the “drawrectangle” function in each of the frames.
You can refer to following MATLAB documentation link for more details about “drawrectangle” function-
As the second step, you can use the “imcrop” function to crop the selected ROI from the frames.
You can refer to following MATLAB documentation link for more details about “imcrop” function-
To extract the RGB values from the selected ROI, the steps are as follows-
The imread function will read any image :
A = imread('myimage.jpg');
Then for the RGB values you can use the sample code below:
R = A(:,:,1);
G = A(:,:,2);
B = A(:,:,3);
The red layer R is the first slice, blue B is the second slice, and green G is the third slice.

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 6 月 3 日
  3 件のコメント
Image Analyst
Image Analyst 2022 年 9 月 29 日
I don't. I just use the entire image. If you wanted to you could crop thisFrame to some rectangular region using indexing or imcrop().
thisFrame = thisFrame(row1:row1, col1:col2, :);
Or you could have a binary image with some irregular shape to use as a mask.
meanGrayLevels(frame) = mean(grayImage(mask));
Shu-An Hsieh
Shu-An Hsieh 2022 年 9 月 29 日
Thank you!
Another question I have is that how can you separate the rgb into separate plots? I try to use the subplot but it did not work.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by