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?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by