Plot an interpolated plane in between two planes
4 ビュー (過去 30 日間)
古いコメントを表示
I have two ground truth depth images (image 1 and image 2) which are located at different distances (150 cm and 203 cm) from the camera. Both the depth images are perpendicular to the camera. I am uploading here the original images.
I'd like to get a middle image by interpolation which will be in between these images (see the illustration).
Illustration:

To do that, I have first cropped the object from the images and then planning to use scatteredinterpolant function to get the interpolated plane in between these two images. However, I am struggling how exactly should I define the interpolation to get the interpolated plane.
I have attached here the depth images and the cropped images and a bit of codes which I did so far.
Any suggestions?
Note: I already have a middle ground truth depth image which is located at 178 cm. I need the interpolated plane so that I can compare the accuracy of the ground truth image with the interpolated plane/surface.
thresholdValue = 10;
originalImage1 = imread('depth_153.png');
originalImage2 = imread('depth_203.png');
binaryImage1 = originalImage1 > thresholdValue;
binaryImage2 = originalImage2 > thresholdValue;
EdgeMeasurements1 = regionprops(binaryImage1, originalImage1, 'all');
EdgeMeasurements2 = regionprops(binaryImage2, originalImage2, 'all');
croppedImage1 = imcrop(originalImage1, EdgeMeasurements1.BoundingBox);
croppedImage2 = imcrop(originalImage2, EdgeMeasurements2.BoundingBox);
x = 1:size(croppedImage1,1);
y = 1:size(croppedImage1,2);
[X,Y] = meshgrid(x,y);
0 件のコメント
採用された回答
KSSV
2018 年 7 月 31 日
thresholdValue = 10;
originalImage1 = imread('depth_153.png');
originalImage2 = imread('depth_203.png');
binaryImage1 = originalImage1 > thresholdValue;
binaryImage2 = originalImage2 > thresholdValue;
I = cat(3,binaryImage1,binaryImage2) ;
[nx,ny] = size(binaryImage1) ;
[X,Y,D] = ndgrid(1:nx,1:ny,[153 203]) ;
[Xi,Yi,Di] = ndgrid(1:nx,1:ny,[153 178 203]) ;
Ii = interpn(X,Y,D,double(I),Xi,Yi,Di) ;
5 件のコメント
Sumayyah Alhydary
2021 年 4 月 21 日
編集済み: Sumayyah Alhydary
2021 年 4 月 21 日
Thanks for your discussion it's very helpful.
I'm getting this error when I run the code:
Error using griddedInterpolant
The sample points arrays must have the same size as the sample values array.
I think the problem is with the way I'm reading the image, so my I = 250 x 250 x 6 while x,y,z are of size 250 x 250 x 2. How can I fix that if I'm using a grayscaled images? ( I don't want the colors to be either black or white, I want them to have different gray values).
how can I fix that?
Thanks in advance :)
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

