>> >> >> |
castle = iread('castle_sign.jpg', 'double');
iprint(castle, 'sign1');
castle = iread('castle_sign.jpg', 'grey', 'double');
|
>> | ithresh(castle) |
>> | t = otsu(castle) |
>> >> >> >> |
castle = iread('castle_sign2.png', 'double', 'grey');
iprint(castle, 'thresh_orig');
ihist(castle, 'b');
iprint('thresh_hist');
|
>> >> >> >> | t = otsu(castle) iprint(castle>t, 'thresh_otsu'); iprint(castle>0.50, 'thresh_050'); iprint(castle>0.60, 'thresh_060'); |
>> >> | t=niblack(castle, -0.2, 35); idisp(t) |
>> >> >> | idisp(castle>t) iprint(t, 'thresh_niblack_t') iprint(castle>t, 'thresh_niblack_result') |
>> | [mser,nsets] = imser(castle, 'light'); |
>> | nsets |
>> >> >> | idisp(mser, 'colormap', 'jet')
idisp(mser, 'colormap', 'jet', 'nogui')
iprint('sign_mser');
|
>> >> >> |
im_targets = iread('yellowtargets.png', 'gamma', 'sRGB', 'double');
z = iread('yellowtargets.png', 'double');
iprint(z, 'targets');
|
>> >> >> |
im_garden = iread('tomato_124.jpg', 'gamma', 'sRGB', 'double');
z = iread('tomato_124.jpg', 'double');
iprint(z, 'tomatoes');
|
>> >> | randinit [cls, cxy,resid] = colorkmeans(im_targets, 4); |
>> | cxy |
>> | colorname(cxy(:,3), 'xy') |
>> | resid |
>> >> >> | idisp(cls, 'colormap', 'flag')
idisp(cls, 'nogui', 'colormap', 'flag')
iprint('targets_seg')
|
>> | cls3 = (cls == 3); |
>> >> | targets_binary = iopen(cls3, kcircle(2)); iprint(targets_binary, 'targets_clean'); |
>> >> >> >> >> >> >> | randinit [cls, cxy] = colorkmeans(im_garden, 4); cxy
idisp(cls, 'nogui', 'colormap', 'flag')
iprint('tomatoes_seg')
xycolorspace(cxy);
iprint('tomatoes_xy');
|
>> >> | tomatoes_binary = iclose(cls2, kcircle(15)); iprint(tomatoes_binary, 'tomatoes_clean'); |
>> | im = ilabeltest; |
>> | idisp(im) |
>> | m |
>> | label |
>> | [label, m, parents, cls] = ilabel(im); |
>> | parents' |
>> | parents(4) |
>> | cls' |
>> >> >> >> | targets_label = ilabel(targets_binary); idisp(targets_label, 'colormap', 'jet');
idisp(targets_label, 'nogui', 'colormap', 'jet');
iprint('targets_label');
|
>> >> >> >> | tomatoes_label = ilabel(tomatoes_binary); idisp(tomatoes_label, 'colormap', 'jet');
idisp(tomatoes_label, 'nogui', 'colormap', 'jet');
iprint('tomatoes_label');
|
>> >> >> >> | [label, m] = igraphseg(im, 1500, 100, 0.5); m idisp(label, 'colormap', 'jet') iprint(label, '58060_seg', 'colormap', 'jet'); |
>> >> >> | reg5 = (targets_label == 5); idisp(reg5); idisp(reg5, 'nogui', 'invert') |
>> | sum(reg5(:)) |
>> | [v,u] = find(reg5); |
>> | about(u) |
>> >> >> >> | umin = min(u) umax = max(u) vmin = min(v) vmax = max(v) |
>> | plot_box(umin, vmin, umax, vmax, 'b') |
>> | m00 = mpq(reg5, 0, 0) |
>> >> | uc = mpq(reg5, 1, 0) / m00 vc = mpq(reg5, 0, 1) / m00 |
>> >> | u20 = upq(reg5, 2, 0); u02 = upq(reg5, 0, 2); u11 = upq(reg5, 1, 1); J = [ u20 u11; u11 u02] |
>> | lambda = eig(J) |
>> | ab = 2 * sqrt(lambda / m00) |
>> | ab(1)/ab(2) |
>> >> | [x,lambda] = eig(J); x |
>> | v = x(:,end); |
>> | atan2( v(2), v(1) ) * 180/pi |
>> >> >> >> >> >> >> | plot_ellipse(4*J/m00, [uc, vc], 'r');
clf
idisp(reg5, 'nogui', 'invert');
hold on
plot(uc, vc, 'gx'); plot(uc, vc, 'go');
plot_ellipse(4*J/m00, [uc, vc], 'r');
iprint('equiv_ellipse');
|
>> | blob = imoments(reg5) |
>> >> >> | blob.uc blob.theta blob.shape |
>> >> | blob.moments.m00 blob.moments.u11 |
>> | f = iblobs(targets_binary) |
>> >> >> >> >> | f(1).class f(1).parent f(1).touch f(1).umin f(1).shape |
>> |
f(1).plot_box('g')
|
>> |
f.plot_box('r:')
|
>> | f(4).children |
>> | f = iblobs(tomatoes_binary, 'area', [1000, 5000]) |
>> | f = iblobs(tomatoes_binary, 'touch', 0) |
>> |
im = iread('P2.png');
|
>> >> | [f,L] = iblobs(im, 'class', 1); f |
>> >> | humoments(L==2) humoments(L==4) |
>> | f = iblobs(tomatoes_binary, 'boundary', 'class', 1) |
>> | size(f(1).edge) |
>> | f(1).edge(:,1:5) |
>> |
f(1).plot_boundary('g.')
|
>> >> >> >> >> | idisp(tomatoes_binary) idisp(tomatoes_binary, 'nogui');
f.plot_boundary('r.')
f.plot_box('g')
iprint('tomatoes_perim');
|
>> |
im = iread('P2.png');
|
>> >> >> >> | f = iblobs( im, 'boundary', 'class', 1) idisp(im, 'nogui') f.plot() iprint(im, 'letterP'); |
>> | f(2).area / f(1).area |
>> | sqrt(ans) |
>> | (f(2).theta - f(1).theta) * 180/pi |
>> | f(1).boundary(); |
>> >> >> >> >> >> >> >> >> >> >> >> | [r1,theta1] = f(1).boundary();
clf
f(1).boundary('b-')
hold on
f(2).boundary('r-')
grid
set(gca,'ydir', 'reverse')
axis square
xlabel('u (pixels)')
ylabel('v (pixels)')
iprint('Pboundary');
clf
|
>> | plot(theta1, r1) |
>> >> >> >> >> >> >> | [r2, theta2] = f(2).boundary(); hold on
plot(theta1, r1, theta2, r2);
xaxis(-pi, pi);
xlabel('\theta'); ylabel('r'); legend('region 1', 'region 2')
iprint('Ppolar')
clf
|
>> | [sim,scale] = boundmatch(r1, r2); |
>> >> >> >> >> | plot(theta1, sim)
xaxis(-pi, pi);
xlabel('theta (rad)');
ylabel('similarity')
iprint('Pxcorr')
|
>> >> | x = peakfit2(theta1, sim); x * 180/pi |
>> | 1/scale |
>> >> >> >> >> |
im = iread('5points.png', 'double');
iprint(im, '5points');
h = Hough(im);
h.show();
iprint('5points_hough');
|
>> >> |
im = testpattern('squares', 256, 256, 128);
im = irotate(im, -0.3);
|
>> | h = Hough(edges) |
>> >> >> >> | h.show();
iprint('hough2');
axis([-1.40 -1.1 -190 -110]);
iprint('hough2a');
|
>> | lines = h.lines() |
>> | h = Hough(edges, 'suppress', 5) |
>> | lines = h.lines() |
>> >> >> >> >> |
idisp(im);
h.plot('g')
idisp(im, 'nogui');
h.plot('g')
iprint('hough3');
|
>> >> >> >> |
im = iread('church.png', 'grey', 'double');
edges = icanny(im);
h = Hough(edges, 'suppress', 5);
lines = h.lines();
|
>> >> | idisp(im); lines(1:10).plot(); |
>> | lines = lines.seglength(edges); |
>> | lines(1) |
>> | k = find( lines.length_v > 100); |
>> >> >> >> >> |
lines(k).plot('g')
idisp(im, 'nogui');
lines(1:10).plot();
lines(k).plot('g');
iprint('church_hough');
|
>> >> |
b1 = iread('building2-1.png', 'grey', 'double');
idisp(b1)
|
>> | C = icorner(b1, 'nfeat', 200); |
>> >> >> >> >> >> >> |
idisp(b1, 'dark');
C.plot('ws');
idisp(b1, 'nogui', 'dark');
C.plot('ws');
iprint('building_1');
xaxis(400, 900); yaxis(50, 350);
iprint('building_1_zoom');
|
>> | C1 = icorner(b1, 'nfeat', 200, 'suppress', 10); |
>> | length(C) |
>> | C(1:4) |
>> >> | C(1:5).strength C(1).u |
>> | C(1:5:100).plot() |
>> | [C,strength] = icorner(b1, 'nfeat', 200); |
>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> | idisp(strength, 'invsigned')
idisp(strength, 'invsigned', 'nogui')
axis([300 500 300 500]);
iprint('harris_corner_image');
s = strength;
[n,x] = hist(s, 100);
cc = cumsum(n);
plot(x,cc/max(cc))
grid
xaxis(max(x)); yaxis(0.8, 1);
xlabel('corner strength');
ylabel('cumulative number of features');
iprint('harris_cdf')
idisp(strength, 'nogui')
C.plot('g+')
axis([460 475 150 165])
iprint('harris_corner_zoom');
|
>> | ihist(strength, 'normcdf') |
>> |
b2 = iread('building2-2.png', 'grey', 'double');
|
>> >> >> >> >> >> >> >> |
C2 = icorner(b2, 'nfeat', 200);
idisp(b2,'dark')
C2.plot('ws');
idisp(b2, 'nogui', 'dark')
C2.plot('ws');
iprint('building_2');
xaxis(200, 700); yaxis(50, 350);
iprint('building_2_zoom');
|
>> >> >> |
im = iread('scale-space.png', 'double');
idisp(im, 'nogui', 'square');
iprint('ss-image');
|
>> >> >> >> >> >> >> >> >> | [G,L,s] = iscalespace(im, 60, 2);
k=5
idisp(L(:,:,k), 'invsigned', 'nogui', 'square'); text(10, 180, sprintf('sigma = %f', s(k))); hold on; plot(64, 64, 'k+'); plot(128, 64, 'k+'); plot(64, 128, 'k+'); plot(128, 128, 'k+'); hold off; iprint('ss-5');
k=20
idisp(L(:,:,k), 'invsigned', 'nogui', 'square'); text(10, 180, sprintf('sigma = %f', s(k))); hold on; plot(64, 64, 'k+'); plot(128, 64, 'k+'); plot(64, 128, 'k+'); plot(128, 128, 'k+'); hold off; iprint('ss-20');
k=35
idisp(L(:,:,k), 'invsigned', 'nogui', 'square'); text(10, 180, sprintf('sigma = %f', s(k))); hold on; plot(64, 64, 'k+'); plot(128, 64, 'k+'); plot(64, 128, 'k+'); plot(128, 128, 'k+'); hold off; iprint('ss-35');
k=55
idisp(L(:,:,k), 'invsigned', 'nogui', 'square'); text(10, 180, sprintf('sigma = %f', s(k))); hold on; plot(64, 64, 'k+'); plot(128, 64, 'k+'); plot(64, 128, 'k+'); plot(128, 128, 'k+'); hold off; iprint('ss-55');
|
>> >> >> >> >> | idisp(L(:,:,5), 'invsigned')
clf; plot(s(1:end-1), -[squeeze(L(64,64,:)) squeeze(L(64,128,:)) squeeze(L(128,64,:)) squeeze(L(128,128,:))])
xaxis(s(end))
grid; xlabel('scale'); ylabel('|LoG|'); legend('5x5', '9x9', '17x17', '33x33')
iprint('ss-plot');
|
>> | s(5) |
>> | f = iscalemax(L, s) |
>> >> >> | idisp(im) idisp(im, 'nogui');
f(1:4).plot('g*')
|
>> |
im = iread('lena.pgm', 'double');
|
>> | [G,L] = iscalespace(im, 8, 8); |
>> >> >> >> >> >> >> | idisp(G, 'flatten', 'wide', 'square');
idisp(G, 'flatten', 'wide', 'square', 'nogui');
iprint('scalespace_g', 'nogrid')
idisp(L, 'flatten', 'wide', 'square', 'invsigned');
idisp(L, 'flatten', 'wide', 'square', 'invsigned', 'nogui');
iprint('scalespace_l', 'nogrid')
delete(gcf)
|
>> | surf1 = isurf(b1) |
>> | surf1(1) |
>> >> >> >> >> |
idisp(b1, 'dark');
surf1(1:50:end).plot_scale('g', 'clock')
idisp(b1, 'nogui', 'dark');
surf1(1:50:end).plot_scale('g', 'clock')
iprint('sift_features', 'nogrid');
|