フィルターのクリア

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

5 ビュー (過去 30 日間)
Kumar Arindam Singh
Kumar Arindam Singh 2017 年 4 月 1 日
編集済み: Kumar Arindam Singh 2017 年 4 月 4 日

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 Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by