How to remove white border from image?

조회 수: 5 (최근 30일)
mark palmer
mark palmer 2020년 7월 25일
편집: mark palmer 2020년 7월 25일
% This draws a small transparent white square in upper left hand side of the group image.
% How do I remove white border of the gcf, and preserve original dimensions of E at 72ppi in saved file?
% BORDER TIGHT seems to have no effect.
clear all
E = imread('visionteam.jpg');
hold on
h1 = imshow(E,'Border','tight')
I = 255 - uint8(zeros(100, 100, 3));
h2 = imshow(I,'Border','tight')
set(h2, 'AlphaData', .35)
hold off
print(gcf,'im','-dtiff','-r72');

채택된 답변

Image Analyst
Image Analyst 2020년 7월 25일
Try this:
rgbImage = imread('visionteam.jpg');
hold on
imshow(rgbImage,'Border','tight')
whiteSquare = 255 * ones(100, 100, 'uint8');
rgbImage(1:100, 1:100, 1) = whiteSquare; % Load into red channel.
rgbImage(1:100, 1:100, 2) = whiteSquare; % Load into red channel.
rgbImage(1:100, 1:100, 3) = whiteSquare; % Load into red channel.
imshow(rgbImage)
% imwrite(rgbImage, filename); % Save to disk if you want.
  댓글 수: 1
mark palmer
mark palmer 2020년 7월 25일
편집: mark palmer 2020년 7월 25일
Thanks! The border is gone, but I need the white square to be transparent.
EDIT:: I think I got it, thanks again.
rgbImage(1:100, 1:100, :) = imadd(rgbImage(1:100, 1:100, :)*.75,whiteSquare*.25);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by