Combine two images from two callbacks

1 回表示 (過去 30 日間)
as hz
as hz 2014 年 8 月 26 日
回答済み: Geoff Hayes 2014 年 8 月 26 日
Hi,
One of the images is based on setappdata in a callback
setappdata(handles.imageAxes, 'IVariable', displayedImage.cdata);
and the other one is a handles.myImage , which is mainly a I = imread(fullFileName) in another callback.
The script below is not working and I think it is because of the cdata, how can I fix it?
Thanks a lot.
Script:
I = getappdata(handles.imageAxes , 'IVariable');
X = handles.myImage;
Icombine = [X I];
figure
imshow(Icombine);
  2 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 8 月 26 日
When you say it is not working, do you mean that there is an error message, and if so, what is it?
What are the dimensions of X and I?
as hz
as hz 2014 年 8 月 26 日
They have different dimensions, an example:
cdata 370x555x3 uint8
I 735x1106x3 uint8
Errors are: Error using vertcat CAT arguments dimensions are not consistent.
Error in TRY4>combineButton_Callback (line 433) Icombine = [X I];

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

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 8 月 26 日
Due to the different number of rows, the error message makes sense. Though I would have expected a
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
if the line code is
Icombine = [X I];
The error message you posted (with vertcat) implies that you are combining the images one of above the other as
[X ; I]
So, if horizontal concatenation (first method), then the two images need to have the same number of rows. If vertical concatenation (second method) then the two images need to have the same number of columns. In order to get the same number of rows (or columns) then you can use imresize, if you have the Image Processing Toolbox.
Or, you can concatenate a portion of the larger image with the smaller one. For example,
Icombine = [X I(1:370,:,:)];
Though you will obviously lose some of the larger image in this combination.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by