how can i remove white spaces around this image ?

조회 수: 5 (최근 30일)
Israa Alqaraleh
Israa Alqaraleh 2017년 6월 26일
댓글: Image Analyst 2017년 6월 27일

채택된 답변

Gopichandh Danala
Gopichandh Danala 2017년 6월 26일
img = imread('whiteBG.jpg');
img = rgb2gray(img);
figure, imshow(img)
% count the pixels of each bin
[counts, bins] = imhist(img);
[M, I] = max(counts);
tempImg = img;
% we know that max pixels in image are white so change all pxiels in that
% bin and above to zero
tempImg(img >= bins(I)-1) = 0;
figure, imshow(tempImg)
% clear some traces or blobs having area less than 30 pixels ...
% (can change according to requirement)
BW = bwareaopen(tempImg,30);
figure, imshow(BW)
  댓글 수: 5
Israa Alqaraleh
Israa Alqaraleh 2017년 6월 27일
i will try it thank you
Israa Alqaraleh
Israa Alqaraleh 2017년 6월 27일
the results good for this image but when I applied it on another image it didn't work will !

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

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 6월 27일
It looks reasonably well cropped right now. Why do you need to chop off a few pixels more? What's the need? I think you can do what you need to do without cropping to the bounding box, so why bother?
  댓글 수: 5
Israa Alqaraleh
Israa Alqaraleh 2017년 6월 27일
I tried to use hough before i think I have a problem using it .
clc ; close all ; img = imread('ko.jpg'); img = rgb2gray(img); % count the pixels of each bin [counts, bins] = imhist(img); [M, I] = max(counts); tempImg = img; % we know that max pixels in image are white so change all pxiels in that % bin and above to zero tempImg(img >= bins(I)-1) = 0; figure(1), imshow(tempImg) % clear some traces or blobs having area less than 30 pixels ... % (can change according to requirement) BW = bwareaopen(tempImg,30); figure(2), imshow(BW);
%% rotate the bwf image by theta angle using hough transform se = strel('line',30,0); bb1 = imdilate(BW,se); bb1= bwmorph(bb1,'thin',Inf); [H,T,R] = hough(bb1,'RhoResolution',0.5,'ThetaResolution',0.5); P = houghpeaks(H,1); x = T(P(:,2)); y = R(P(:,1)); lines = houghlines(bb1,T,R,P,'FillGap',5,'MinLength',20);
what next ?
Image Analyst
Image Analyst 2017년 6월 27일
I already told you what to do next if that didn't work: "If that doesn't work you can......". See my above comment.

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

카테고리

Help CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by