convert BGRA8 image format to RGB format

조회 수: 3 (최근 30일)
L
L 2021년 10월 12일
댓글: L 2021년 10월 16일
Is there a built-in function for conversion of BGRA8 image to RGB image? If there is no available function for the conversion, is there a way to make this conversion?

채택된 답변

Jan
Jan 2021년 10월 12일
Do you have the pixels values as UINT8 array already? Then:
RGB = BGRA8(:, :, [3, 2, 1])
  댓글 수: 7
L
L 2021년 10월 13일
I have accessed the field again in the Command Window, but my RGB image is wrong.
Maybe there is a problem with the array conversion?
L
L 2021년 10월 13일
편집: L 2021년 10월 13일
The issue with the structure is solved. The solution is to call the receive() function.
But, still there is a problem with the conversion from BGRA8 to RGB.
What can be the problem here?
Here is the screenshot, and the code. The BGRA8 image is 1010688x1 uint8 array.
msg = receive(sub);
img=msg.Data;
outImg = reshape(img, 672, 376, []);
outImg1=permute(outImg, [2 1 3 4]);
rgb=outImg1(:,:,[2 1 3]);
figure, imshow(rgb);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Cam Salzberger
Cam Salzberger 2021년 10월 13일
Since the image data is coming out of a ROS message, you can use the ROS functions to extract the image from it:
Message object - readImage method
Message struct - rosReadImage function
-Cam
  댓글 수: 1
L
L 2021년 10월 16일
Thank you, the problem is solved now

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Specialized Messages에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by