clc;clear all;close all;c0 = 2;imgID = 5; Img = imread(char(strcat(int2str(imgID),'.jpg'))) ;Img = double(Img(:,:,1));switch imgID case 1 iterNum = 700; lambda1 = 1.0; lambda2 = 1.0; nu = 0.004*255*255; initialLSF = ones(size(Img(:,:,1))).*c0; initialLSF(30:70,20:90) = -c0; case 2 iterNum = 500; lambda1 = 1.0; lambda2 = 0.8; nu = 0.002*255*255; initialLSF = ones(size(Img(:,:,1))).*c0; initialLSF(26:32,28:34) = -c0; case 3 iterNum =800; lambda1 = 1.0; lambda2 = 1.0; nu = 0.003*255*255; initialLSF = ones(size(Img(:,:,1))).*c0; initialLSF(15:78,32:95) = -c0; case 4 iterNum = 500; lambda1 = 1.0; lambda2 = 1.0; nu = 0.001*255*255; initialLSF = ones(size(Img(:,:,1))).*c0; initialLSF(53:77,46:70) = -c0; case 5 iterNum = 700; lambda1 = 1.0; lambda2 = 0.8; nu = 0.001*255*255; initialLSF = ones(size(Img(:,:,1))).*c0; initialLSF(47:60,86:99) = -c0;endu = initialLSF;figure;imagesc(Img, [0, 255]);colormap(gray);hold on;axis off,axis equaltitle('Initial contour');[c,h] = contour(u,[0 0],'r');pause(0.1);timestep = .1; mu = 1;epsilon = 1.0; sigma=3.0; K=fspecial('gaussian',round(2*sigma)*2+1,sigma); I = Img;KI=conv2(Img,K,'same'); KONE=conv2(ones(size(Img)),K,'same')for n=1:iterNum uold = u; u=RSF(u,I,K,KI,KONE, nu,timestep,mu,lambda1,lambda2,epsilon,1); ux = norm(u-uold);if( ux <= 15) breakend if mod(n,20)==0 pause(0.1); imagesc(Img, [0, 255]);colormap(gray);hold on;axis off,axis equal [c,h] = contour(u,[0 0],'r'); iterNum=[num2str(n), ' iterations']; title(iterNum); hold off; endend g=imagesc(Img, [0, 255]);colormap(gray);hold on;axis off,axis equal %MARKED
[c,h] = contour(u,[0 0],'r'); %MARKEDimwrite(g, 'F:/output/filename.jpg','jpg'); %MARKEDtotalIterNum=[num2str(n), ' iterations'];title(['Final contour, ', totalIterNum]);I = im2double(imread('output5.jpg')); c_diag = corrcoef(I(1:end-1, 1:end-1), I(2:end, 2:end)) A=imread('output5.jpg'); ref=imread(char(strcat(int2str(imgID),'.jpg'))) ; ssimval = ssim(A,ref); fprintf('The SSIM value is %0.4f.\n',ssimval);
MATLAB: Instead its type was matlab.graphics.primitive.Image.
i am unable to write this image to the folder
Best Answer