combine binary image

3 views (last 30 days)
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
setappdata(handles.cJalan, 'jalan_', jalan);
jalan = zeros(p,l, 'uint8');
setappdata(handles.cJalan, 'jalan_', jalan);
% handles.jalan = jalan;
% -----------------------------------------
%%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
setappdata(handles.cSungai, 'sungai_', sungai);
sungai = zeros(p,l, 'uint8');
setappdata(handles.cSungai, 'sungai_', sungai);
% ---------------------------------------
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
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..

Accepted Answer

Chandra Kurniawan
Chandra Kurniawan on 9 Mar 2012
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};
I hope this works!
Chandra Kurniawan
Chandra Kurniawan on 10 Mar 2012
Please see your question page :

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!