How do I make shape display in black colour and background in white colour?

3 ビュー (過去 30 日間)
This is my code below
subplot(1,3,1); % subplot(m,n,p) m and n define the array of all the images together, and p defines the position of this particular plot in that array
%as an example subplot(1,3,1) says that there is 1 row of plots, 3 columns
%and the following plot should be placed in position 1
% Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
imageSizeX = 640;
imageSizeY = 480;
[columnsInImage, rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY); % Next create the circle in the image.
centerX = 320;
centerY = 240;
radius = 100;
circlePixels = (rowsInImage - centerY).^2 ... + (columnsInImage - centerX).^2 <= radius.^2;
% circlePixels is a 2D "logical" array.
% Now, display it.
image(circlePixels) ;
colormap([0 0 0; 1 1 1]);
axis equal; %makes circle look like a circle by giving axis equal distribution
axis off; %hide the axis
subplot(1,3,2);
% Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
imageSizeX = 640;
imageSizeY = 480;
[columnsInImage, rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY); % Next create the circle in the image.
xCenter = 12;
yCenter = 10;
% Modification to the FAQ is the next two lines.
numSides = 7; % <=== CHANGE THIS NUMBER
theta = linspace(0, 2*pi, numSides);
radius = 8;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y);
axis square;
xlim([0 20]);
ylim([0 20]);
grid on;
axis equal; %makes circle look like a circle by giving axis equal distribution
axis off;
axis equal; %makes circle look like a circle by giving axis equal distribution
axis off; %hide the axis
subplot(1,3,3);
% Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
imageSizeX = 640;
imageSizeY = 480;
[columnsInImage, rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
% Next create the circle in the image.
centerX = 320;
centerY = 240;
radius = 100;
circlePixels = (rowsInImage - centerY).^2 ... + (columnsInImage - centerX).^2 <= radius.^2;
% circlePixels is a 2D "logical" array.
% Now, display it.
image(circlePixels) ;
colormap([0 0 0; 1 1 1]);
axis equal; %makes circle look like a circle by giving axis equal distribution
axis off; %hide the axis

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 3 日
Just do
image(~circlePixels);
Or else change your colormap
colormap([1, 1, 1; 0, 0, 0]);
  2 件のコメント
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 3 日
Hello image analyst in this code my other background is showing cream how do I change that?
Image Analyst
Image Analyst 2015 年 5 月 3 日
In your computer settings for your display or display adapter (nothing to do with MATLAB), there is a setting for color temperature. Like 3200, 5500, 6500, 9500, etc. Try different ones until the white is the shade of white that is most preferable to you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFormat and Export Documents and Graphics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by