필터 지우기
필터 지우기

how can i find pixels of image's border

조회 수: 4 (최근 30일)
bay rem
bay rem 2015년 12월 28일
답변: harjeet singh 2015년 12월 28일
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:
i will appreciate any help ,thank you ^^

채택된 답변

harjeet singh
harjeet singh 2015년 12월 28일
you may use this code do set the th val according to the boarder noise
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)

추가 답변 (1개)

Image Analyst
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, :) = [];

카테고리

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