combine binary image

3 次查看(过去 30 天)
I have a code like this
%%function of checkbox: cJalan -------
jalan = get(handles.aJalan, 'Userdata');
[p, l] = size(jalan);
nil = get(handles.cJalan, 'Value');
if nil == 1
jalan;
setappdata(handles.cJalan, 'jalan_', jalan);
else
jalan = zeros(p,l, 'uint8');
setappdata(handles.cJalan, 'jalan_', jalan);
% handles.jalan = jalan;
end
% -----------------------------------------
%%function of checkbox: cSungai
function cSungai_Callback(hObject, eventdata, handles)
sungai = get(handles.aSungai, 'Userdata');
[p, l] = size(sungai);
nil = get(handles.cSungai, 'Value');
if nil == 1
sungai;
setappdata(handles.cSungai, 'sungai_', sungai);
else
sungai = zeros(p,l, 'uint8');
setappdata(handles.cSungai, 'sungai_', sungai);
end
% ---------------------------------------
and 3 checkboxs other. i used them to combine their object, the object of 'cJalan' is 'jalan', and object of 'cSungai' is 'sungai'
each object will be called to combine the objects into a frame.. and i try to used this code to combine them..
to illustrate the problem, u can look this picture http://www.flickr.com/photos/77405333@N03/6791139372/
j = getappdata(handles.cJalan, 'jalan_');
s = getappdata(handles.cSungai, 'sungai_');
l = getappdata(handles.cLapangan, 'lapangan_');
sa = getappdata(handles.cSawah, 'sawah_');
g = getappdata(handles.cGedung, 'gedung_');
gabung = j|s|l|sa|g;
l, sa and g have same code with 2 checkbox others. in this case, 3 checkbox is unchecked.
how I can combine them, although not all axes fully.. do you have any example code with this problem..?? thanks..

采纳的回答

Chandra Kurniawan
Hi,
I think, first you should check whether the data is empty or not using for-loop.
hnd = {handles.cJalan,handles.cSungai,handles.cLapangan,handles.cSawah,handles.cGedung};
var = {'jalan_','sungai_','lapangan_','sawah_','gedung_'};
% I assume that the images have 256x256 dimension
gabung = logical(zeros([256 256]));
for x = 1 : 5
v{x} = getappdata(hnd{x},var{x});
if ~isempty(v{x})
gabung = gabung | v{x};
end
end
imshow(gabung);
I hope this works!
  2 个评论
Rahma Yeni
Rahma Yeni 2012-3-10
thank you Chandra... Now, my picture can be combined ... your code really helped me,, :) :) ^^ thanks.. I want to ask one more... how i can make history like in Photoshop..??? Where, when I choose a process, the process will be included in a list .. Then if I choose the second process, the second process will be listed under the first process.. i illustrate it like this
http://www.flickr.com/photos/rye_ni/6822456324/in/photostream
i hope, you can help me again... thanks before.. :)
Chandra Kurniawan
Chandra Kurniawan 2012-3-10
Please see your question page :
http://www.mathworks.com/matlabcentral/answers/31729-make-history

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by