Function that takes 2 input matrices (mxn3 color uint8 and mxn matrix of doubles) and returns an mxnx3 color image.
조회 수: 3 (최근 30일)
이전 댓글 표시
I am not asking for the answer to what obviously looks like a hw assignment but rather I am just asking for some direction and clarification. I am not even sure where to start or what exactly I am being asked to do...If someone could just help me understand this prompt or point me towards what topics I should read up on, I would be much obliged.
Write a program that takes an m x n x 3 color image uint8 matrix, and an m x n matrix of doubles as inputs. It should return an m x n x 3 color image.
Your program should:
- Convert your matrix of doubles to a matrix of uint8s.
- Combine the information from the matrix with the information from EACH COLOR of the image matrix. You should do this by dividing both matrices by 2, and then adding them together in an appropriate way.
- Returned the combined matrices as your outputs.
function [] = matrixCombine(colorImage,doubleImage)
doubleImage = doubleImage./2
colorImage(:,:,1)= colorImage(:,:,1)./2 + doubleImage
colorImage(:,:,2)= colorImage(:,:,2)./2 + doubleImage
colorImage(:,:,3)= colorImage(:,:,3)./2 + doubleImage
is all I have so far. Sorry that I obviously have some major gaps in my understanding of programming in MATLAB but I am trying to improve. Thank you for your help.
댓글 수: 2
Walter Roberson
2018년 3월 19일
You are missing the step "Convert your matrix of doubles to a matrix of uint8s."
Your function is not returning anything.
답변 (1개)
Venkata Siva Krishna Madala
2018년 3월 22일
Hello Ray,
I understood your problem and wrote the code as needed.
function outputImage = matrixCombine(colorImage,doubleImage)
t=uint8(doubleImage);
t=t./2;
outputImage(:,:,1)= colorImage(:,:,1)./2 + t;
outputImage(:,:,2)= colorImage(:,:,2)./2 + t;
outputImage(:,:,3)= colorImage(:,:,3)./2 + t;
end
Also, check https://www.mathworks.com/help/matlab/numeric-types.html. It that will help you get a deeper understanding of the Numeric Data Types in MATLAB
Regards,
Krishna Madala
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!