필터 지우기
필터 지우기

Kron function for 3D matrix

조회 수: 6 (최근 30일)
Baptiste
Baptiste 2014년 6월 9일
댓글: Sean de Wolski 2014년 6월 11일
Actually, I study on a project where I must integrate a colored image (that mean, RGB, so a 3D Matrix 153x203x3), into a depth image (a 2D matrix with a depth value 144x176).
The problem is the difference of size (x,y) of each image: The depth camera has less pixels than the RGB camera (144<153, 176<203).
So, I decided to convert each image with the same size, using kron:
Im=imread('3Dcake');
Imkron=kron(img,ones(144,176));
I = double(imkron);
depImg=imread('Depthcake');
depthkron=kron(depImg,ones(153,203));
depth = double(depthkron);
I get this error on line 2:
Integers can only be combined with integers of the same class, or scalar doubles.
Probably because it's a 3D matrix, so, for preserve the RGB values, I tried this version:
Imkron=kron(img,ones(9,11,1));
Same effect, maybe I going on a bad way, otherwise, someone can show to me a solution of this?
  댓글 수: 2
Matt J
Matt J 2014년 6월 10일
편집: Matt J 2014년 6월 10일
I study on a project where I must integrate a colored image...into a depth image
"integrate" is too vague a word for us to know what operation you mean and your posted code doesn't show the step where the integration operation occurs.
Probably because it's a 3D matrix,
As Jan said, your first problem is that imread() does not import in double or single form. However, it is also true that kron does not allow 3D input arguments. Explain better the integration operation that you are trying to do so that we can judge whether kron is even necessary.
Baptiste
Baptiste 2014년 6월 11일
Yeah, I wanted to mean:"Implement" colored image into depth data (Using scatter3 function).
Finally, I get it, combining kron (on depth data) and padarray (to add some missing pixels), like this:
Im = imread('cake.jpg');
load 'depImg.mat';
img = Im(1:3:end, 1:3:end,:);
I=double(img);
depthkron=kron(depImg,ones(2,3));
depth = double(padarray(depthkron,[60 7]));
In add of this, I reduce the resize of my RGB image, so I lost less information (408x542x3). The problem is solved ;) .

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

답변 (1개)

Jan
Jan 2014년 6월 9일
The error message is clear: The type of img is the problem. So try:
Imkron = kron(double(img), ones(144,176));
  댓글 수: 2
Baptiste
Baptiste 2014년 6월 10일
Thank you, that work! But my image lost his 3th dimension, that mean I lost his RGB data.... Kron is not a solution for implement a color image to a depth data.
But thank you!
Sean de Wolski
Sean de Wolski 2014년 6월 11일
@Baptiste, For-loop over the three dimensions...

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

Community Treasure Hunt

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

Start Hunting!

Translated by