### Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

## Function that takes 2 input matrices (mxn3 color uint8 and mxn matrix of doubles) and returns an mxnx3 color image.

rayray

### rayray (view profile)

さんによって質問されました 2018 年 3 月 19 日

### rayray (view profile)

さんによって コメントされました 2018 年 3 月 22 日
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.
1. Convert your matrix of doubles to a matrix of uint8s.
2. 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.
3. 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.

Walter Roberson

### Walter Roberson (view profile)

2018 年 3 月 19 日
You are missing the step "Convert your matrix of doubles to a matrix of uint8s."
Your function is not returning anything.
rayray

### rayray (view profile)

2018 年 3 月 22 日
Thank you! I totally missed that. I managed to get the code to work! I wasn't sure if I was even on the right track so I appreciate your help

サインイン to comment.

## 1 件の回答

### Venkata Siva Krishna Madala (view profile)

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,