How can I make the Background of an image invisible? (R2018b)
조회 수: 1 (최근 30일)
이전 댓글 표시
When I start to plot the image with imread, the image is plot with background. How can I set this background invisible or how I can delete the background?
I tried:
auto = imread('Auto.png', 'BackgroundColor','none') % this code not worked
and I also tried to cut (delete) the Background in other Programms.
Thank you for your help
댓글 수: 4
Johannes Fischer
2019년 9월 25일
auto = imread('auto.png');
% create an alpha channel where the image is more transparent the brighter it is
% (only works with greyscale RG images, as im only using the red channel here)
alpha = 255 - auto(:, :, 1);
% make the lines a bit darker
auto(auto < 220) = 0;
% save image with alpha channel
imwrite(auto, 'auto_tp.png', 'Alpha', alpha)
답변 (1개)
Mahesh Taparia
2019년 9월 30일
Hi,
As per your image, it will be a two-class classification problem in an image. Since the image is a black and white and you want to extract the black pixels, it can be done by converting the image into gray color space and then using Otsu’s thresholding method by using 'multithresh' function to set proper threshold.
You can do so by executing the following lines of code:
auto = imread('auto.png');
Gray_img=rgb2gray(auto);
thres=multithresh(Gray_img);
Segmented_img= Gray_img <thres;
figure;imshow(Segmented_img)
imwrite(Segmented_img, 'auto_segmented.png')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!