필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)

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.

답변 (1개)

Image Analyst
Image Analyst 2017년 4월 1일
Use padarray():
padsize = 1;
padvalue = 255; % or 1 if image is single, double, or logical.
paddedImage = padarray(originalImage, padsize, padval);
  댓글 수: 3
Image Analyst
Image Analyst 2017년 4월 1일
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 2017년 4월 4일
편집: Kumar Arindam Singh 2017년 4월 4일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by