url httpblogsmathworkscomimagessteve2010mmsjpg rgb imreadu

url = \'http://blogs.mathworks.com/images/steve/2010/mms.jpg\';

rgb = imread(url);

imshow(rgb)

%rgb = imread(\'usboutput1.jpg\');

%imshow(rgb)

d = imdistline;

delete(d);

gray_image = rgb2gray(rgb);

imshow(gray_image);

[centers, radii] = imfindcircles(rgb,[15 20],\'ObjectPolarity\',\'dark\')

[centers, radii] = imfindcircles(rgb,[15 20],\'ObjectPolarity\',\'dark\',\'Sensitivity\',0.9)

imshow(rgb);

h = viscircles(centers,radii);

[centers, radii] = imfindcircles(rgb,[15 20],\'ObjectPolarity\',\'dark\',\'Sensitivity\',0.95);

size(centers)

delete(h);

h = viscircles(centers,radii);

[centers, radii, metric] = imfindcircles(rgb,[15 20], ...

\'ObjectPolarity\',\'dark\',\'Sensitivity\',0.95,\'Method\',\'twostage\');

delete(h);

h = viscircles(centers,radii);

[centersBright, radiiBright] = imfindcircles(rgb,[15 20],\'ObjectPolarity\',\'bright\',\'Sensitivity\',0.95);

imshow(rgb);

hBright = viscircles(centersBright, radiiBright,\'EdgeColor\',\'b\');

[centersBright, radiiBright, metricBright] = imfindcircles(rgb,[15 20], ...

\'ObjectPolarity\',\'bright\',\'Sensitivity\',0.95,\'EdgeThreshold\',0.1);

delete(hBright);

hBright = viscircles(centersBright, radiiBright,\'EdgeColor\',\'b\');

h = viscircles(centers,radii);

centers = round([centers; centersBright]);

radii = [radii; radiiBright];

filt_rgb = imfilter(rgb,ones(5)/25);

locs = [repmat(fliplr(centers),3,1) kron((1:3)\',ones(size(centers,1),1))];

center_idx = sub2ind(size(rgb),locs(:,1),locs(:,2),locs(:,3));

cent_color = filt_rgb(center_idx);

cent_color = reshape(cent_color,size(centers,1),3);

imshow(rgb)

for i = 1:size(centers,1)

viscircles(centers(i,:),radii(i),\'EdgeColor\',double(cent_color(i,:))/255);

end

%szdim2 = size(centers,1)

%a=szdim2/2

cartoon_rgb = zeros(size(rgb),class(rgb));

cartoon_rgb(center_idx) = cent_color(:);

imshow(cartoon_rgb)

radius = 17;

circ_mask = double(getnhood(strel(\'ball\',radius,radius,0)));

imshow(circ_mask, \'InitialMagnification\', 500)

cartoon_rgb = imfilter(cartoon_rgb,circ_mask,\'conv\');

imshow(cartoon_rgb)

bg_color = [235; 218; 175];

bw = false(size(rgb,1),size(rgb,2));

bw(sub2ind(size(bw),centers(:,2),centers(:,1))) = true;

bw = imfilter(bw,circ_mask);

bw = imcomplement(bw);

imshow(bw)

bg_idx_gray = find(bw);

bg_idx_color = [bg_idx_gray; numel(bw)+bg_idx_gray; 2*numel(bw)+bg_idx_gray];

bg_fill_values = kron(bg_color,ones(size(bg_idx_gray)));

cartoon_rgb(bg_idx_color) = bg_fill_values;

imshowpair(rgb,cartoon_rgb,\'montage\');

title(\'Spot the difference!\');

axis off;

000000

Solution

Hi,

In the question here, url is \'http://blogs.mathworks.com/images/steve/2010/mms.jpg\'.
The function to swap the function and read the code here is to, strore the current value in a new variable say \'swap\' or \'temp\'. Do not use this for the method delete(), used in the program above.
The function imshow(gray_image), can have the pixel readings correctly inorder to carry out the swap function..
The other functions h= viscircles(Centers, radii), centres = round([centers;centersBright]) can use the above said variable \'temp\' to carry out the function to display code and perform \'swap\'or interchange values operation.

Please clarify if the above is able to get you the answer.

url = \'http://blogs.mathworks.com/images/steve/2010/mms.jpg\'; rgb = imread(url); imshow(rgb) %rgb = imread(\'usboutput1.jpg\'); %imshow(rgb) d = imdistline; d
url = \'http://blogs.mathworks.com/images/steve/2010/mms.jpg\'; rgb = imread(url); imshow(rgb) %rgb = imread(\'usboutput1.jpg\'); %imshow(rgb) d = imdistline; d
url = \'http://blogs.mathworks.com/images/steve/2010/mms.jpg\'; rgb = imread(url); imshow(rgb) %rgb = imread(\'usboutput1.jpg\'); %imshow(rgb) d = imdistline; d

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site