![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172414/image.png)
how can i find pixels of image's border
2 次查看(过去 30 天)
显示 更早的评论
i have a set of images and i would like to test if there is a a black border on limits on the image, such this one:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152896/image.jpeg)
i will appreciate any help ,thank you ^^
0 个评论
采纳的回答
harjeet singh
2015-12-28
you may use this code do set the th val according to the boarder noise
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172414/image.png)
clear all
close all
clc
img=imread('images.jpg');
th=10;
a=img(:,:,1)>th & img(:,:,2)>th & img(:,:,3)>th;
a=bwareaopen(a,5000);
[r,c]=find(a==1);
b=img(min(r):max(r),min(c):max(c),:);
figure(1)
imshow(b)
0 个评论
更多回答(1 个)
Image Analyst
2015-12-28
Your image has white columns on the left and right side - did you know that? So there are no all zero rows. To see if all pixels in a row or column are 0, use all():
allZeroColumns = all(grayImage == 0, 1);
allZeroRows = all(grayImage == 0, 2);
These are logical vectors. If you want, you can then use them to remove all zero rows or columns:
grayImage(:, allZeroColumns) = [];
grayImage(allZeroRows, :) = [];
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!