Borrar filtros
Borrar filtros

How to draw a white border around an image(or a group of images in a folder)

5 visualizaciones (últimos 30 días)

I have an image :-

Now i want to draw a white border around the image,such that i get this:-

How can i do this.Please help.

Respuestas (1)

Image Analyst
Image Analyst el 1 de Abr. de 2017
Use padarray():
padsize = 1;
padvalue = 255; % or 1 if image is single, double, or logical.
paddedImage = padarray(originalImage, padsize, padval);
  3 comentarios
Image Analyst
Image Analyst el 1 de Abr. de 2017
Then just write it in yourself
grayImage(:, 1) = 255; % Make left column white.
grayImage(:, end) = 255; % Make right column white.
grayImage(1, :) = 255; % Make top row white.
grayImage(end, :) = 255; % Make bottom row white.
Kumar Arindam Singh
Kumar Arindam Singh el 4 de Abr. de 2017
Editada: Kumar Arindam Singh el 4 de Abr. de 2017
I have this code: %read image im=imread('2.jpg'); figure,imshow(im); %convert image to grayscale components imr=im(:,:,1); img=im(:,:,2); imb=im(:,:,3);
%write the images to specified folders with a suitable name imwrite(imr, 'C:\Users\hp\Documents\MATLAB\Imageprocessing\project1\001r.jpg','jpg'); imwrite(img, 'C:\Users\hp\Documents\MATLAB\Imageprocessing\project1\001g.jpg','jpg'); imwrite(imb, 'C:\Users\hp\Documents\MATLAB\Imageprocessing\project1\001b.jpg','jpg');
%calculate the level of the blue image using OTSU's threshold function level = graythresh(imb);
%converting the blue component grayscale image to binary image with the %help of level calculated using OTSU's threshold function bwb=im2bw(imb,level);
%show the binary image figure,imshow(bwb);
%save the binary image imwrite(bwb, 'C:\Users\hp\Documents\MATLAB\Imageprocessing\project1\001bin.jpg','jpg'); %tried implementing your code snippet bwb(:,1)=255; bwb(:,end)=255; bwb(1,:)=255; bwb(end,:)=255; figure,imshow(bwb);
There seems to be no effect. I am using MATLAB R2015a

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by