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..
댓글 수: 0
채택된 답변
Chandra Kurniawan
2012년 3월 9일
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
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!