フィルターのクリア

Display multiple images on single axes

19 ビュー (過去 30 日間)
Rao
Rao 2012 年 6 月 24 日
コメント済み: Walter Roberson 2019 年 8 月 26 日
my gui contains a push button to load an rgb image and an axes to display it and another axes to display r g and b planes separately. how can i display these planes at the same time on a single axes ??

採用された回答

Image Analyst
Image Analyst 2012 年 6 月 24 日
Try this demo:
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
[rows columns numberOfColorChannels] = size(rgbImage);
% Make black strips to space them apart
widthOfStrip = 20;
verticalStrip = zeros(rows, widthOfStrip, 'uint8');
horizontalStrip = zeros(widthOfStrip, 2*columns + widthOfStrip, 'uint8');
% Make into color so we can stitch.
horizontalStrip = cat(3, horizontalStrip, horizontalStrip, horizontalStrip);
verticalStrip = cat(3, verticalStrip, verticalStrip, verticalStrip);
% Stitch together
outputImage = [rgbImage, verticalStrip, redChannel; horizontalStrip; greenChannel, verticalStrip, blueChannel];
imshow(outputImage);
  4 件のコメント
Subhadeep Koley
Subhadeep Koley 2019 年 8 月 23 日
The code is giving the following error.
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in image_demo (line 31)
outputImage = [rgbImage, verticalStrip, redChannel; horizontalStrip; greenChannel,
verticalStrip, blueChannel];
Walter Roberson
Walter Roberson 2019 年 8 月 26 日
z = 0 * rgbImage; %same size and type but all 0
redChannel = z;
redChannel(:,:,1) = rgbImage(:, :, 1);
greenChannel = z;
greenChannel(:,:,2) = rgbImage(:, :, 2);
blueChannel = z;
blueChannel(:,:,3) = rgbImage(:, :, 3);

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 6 月 24 日
If you use image() [or imagesc()] to display an image, you can specify the data coordinates to associate with the center of the lower-left pixel and the center of the upper-right pixel.
  2 件のコメント
Rao
Rao 2012 年 6 月 24 日
I=imread('peppers.ppm');
axes(handles.axes1)
imshow(I);
axes(handles.axes2);
imshow(uint8(I(:,:,1)));
imshow(uint8(I(:,:,2)));
imshow(uint8(I(:,:,3)));
this is the callback for push button can you please write code to display the the r g and b planes in axes2
Walter Roberson
Walter Roberson 2012 年 6 月 24 日
Sorry, imshow() does not document the positioning meaning of its XData and YData parameters, so even if I had access to MATLAB to test now, it might change in any release.
I recommend that you instead use a routine whose positioning meanings are documented, image(). See the XData and YData property descriptions at http://www.mathworks.com/help/techdoc/ref/image_props.html

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

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by