how to change the background in imshow from black to white

조회 수: 27 (최근 30일)
Houghton
Houghton 2015년 8월 19일
댓글: Image Analyst 2020년 8월 22일
get(0,'Factory');
set(0,'defaultfigurecolor',[1 1 1]);
whitebg(figure);
set(gcf,'color','white');
set(gca,'color','none');
figure; clf;
imshow(pairOfImages);
The result is this
I want a result that shows the pyramid with a white background.
Thanks
  댓글 수: 1
Morteza
Morteza 2015년 8월 19일
편집: Morteza 2015년 8월 19일
in fact by counting the number of repeated item you can consider what color is dominated by background color and set the new color as user specify it like input and then set new background color. write GUI to analyze it and do the rest...

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

답변 (2개)

Morteza
Morteza 2015년 8월 19일
편집: Morteza 2015년 8월 19일
try this save your picture like Untitled.png on your desktop and then call it from MATLAB like below:
clc,clear all
A = imread('C:\Users\MORTEZA\Desktop\Untitled0.png');
figure(1)
image(A)
[L,W,D] = size(A);
for i = 1:L
for j = 1:W
for k = 1:D
if A(i,j,k) == 0
A(i,j,k) = 255;
end
end
end
end
figure(2)
image(A)
  댓글 수: 3
Keerthi  D
Keerthi D 2020년 6월 29일
편집: Image Analyst 2020년 8월 22일
Sir I tried your code above, but I didn't get.
A=imread('C:\Users\Keerthi Dev\Desktop\matlabwork\seg1.png');
figure(1)
image(A)
[L,W,D] = size(A);
for i = 1:L
for j = 1:W
for k = 1:D
if A(i,j,k) == 0
A(i,j,k) = 255;
end
end
end
end
figure(2)
image(A)
result is:
Sir, please help me to solve my problem
Image Analyst
Image Analyst 2020년 8월 22일
Sure, but please post it in a new post, not tacked onto a 5 years old post from someone else.

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


hf fh
hf fh 2018년 9월 19일
I have a grayscale image, Please help me I have a picture and I want to make the background color white I used the previous method but did not good out with me

카테고리

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