img = imread('lena.png'); gray = rgb2gray(img); // Sobel edge detection edges = edge(gray, 'sobel'); imshow(edges); // To export as PDF-quality figure xs2png(gcf(), 'edges_output.png'); // or xs2pdf for vector output
// Run example result = process_image("sample.jpg");
// Opening (erosion followed by dilation) opened = imopen(binary, se);
// Plot original vs processed scf(0); clf; subplot(1,2,1); imshow(original); title('Original Image'); subplot(1,2,2); imshow(processed); title('Processed Result'); // Export as PDF (vector quality) xs2pdf(gcf(), 'image_comparison.pdf');
// 5. Edge detection sobel_x = [-1 0 1; -2 0 2; -1 0 1]; Gx = imfilter(double(img), sobel_x); Gy = imfilter(double(img), sobel_x'); edges = sqrt(Gx.^2 + Gy.^2);
// Read an image img = imread('C:\Users\YourPhoto.jpg');