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

3 Ansichten (letzte 30 Tage)

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.

Antworten (1)

Image Analyst
Image Analyst am 1 Apr. 2017
Use padarray():
padsize = 1;
padvalue = 255; % or 1 if image is single, double, or logical.
paddedImage = padarray(originalImage, padsize, padval);
  3 Kommentare
Image Analyst
Image Analyst am 1 Apr. 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 am 4 Apr. 2017
Bearbeitet: Kumar Arindam Singh am 4 Apr. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by