piling multiple images in one 3d

조회 수: 14 (최근 30일)
Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 10월 15일
답변: Image Analyst 2019년 3월 13일
I have three rgb images(attached) which I want to pile them in horizontal manner in matlab (shown in figure below)
I have found bug in this code
a=imread('100.jpg');
b=imread('200.jpg');
c=imread('300.jpg');
I = cat(4,a,b,c);
data = importdata('gpheight300.txt') ;
x = data(:,1) ; x = unique(x) ;
y = data(:,2) ; y = unique(y) ;
%# coordinates
[X,Y] = meshgrid(1:size(I,2), 1:size(I,1));
%[X,Y]=meshgrid(x,y);
Z = ones(size(I,1),size(I,2));
kin=[100 200 300];
for k=1:length(kin)
hold on
%surface('XData',X, 'YData',Y, 'ZData',Z.*kin(k), ...
'CData',I(:,:,k), 'CDataMapping','direct', ...
'EdgeColor','none', 'FaceColor', 'texturemap')
% patch('XData',X, 'YData',Y, 'ZData',Z.*kin(k),'CData',I(:,:,k))
%image('XData',X,'YData',Y,'CData',I(:,:,k))
end
%colormap(cmap)
%hold off
view(3), box on,
problem is in surf function which i am using for rgb image?
Can solution possible on this problem
Regards
  댓글 수: 1
KSSV
KSSV 2016년 10월 16일
What bug in the code?

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

답변 (2개)

Image Analyst
Image Analyst 2019년 3월 13일
Try this:
% Takes an RGB image and stacks the separate color channels at different Z levels.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
filename = 'peppers.png';
rgbImage = imread(filename);
% Extract the individual red, green, and blue color channels.
redChannel = im2double(rgbImage(:, :, 1));
greenChannel = im2double(rgbImage(:, :, 2));
blueChannel = im2double(rgbImage(:, :, 3));
H(1) = slice(repmat(redChannel,[1 1 2]),[],[], 1); %slice() requires at least 2x2x2
set(H(1),'EdgeColor','none') %required so image isn't just an edge
hold on
H(2) = slice(repmat(greenChannel,[1 1 2]),[],[], 2); %slice() requires at least 2x2x2
set(H(2),'EdgeColor','none') %required so image isn't just an edge
H(3) = slice(repmat(blueChannel,[1 1 3]),[],[], 3); %slice() requires at least 2x2x2
set(H(3),'EdgeColor','none') %required so image isn't just an edge
hold off
colormap(gray(256))
axis ij
caption = sprintf('R, G, and B Color Channels of %s', filename);
title(caption, 'FontSize', fontSize);
% Put up legend that says what slice is what color channel.
legend('B', 'G', 'R')
Capture.PNG

Image Analyst
Image Analyst 2016년 10월 16일
  댓글 수: 1
pandu repala
pandu repala 2019년 3월 13일
@Muhammad Usman Saleem I am looking for something similar. Were you able to resolve your issue?

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by