How do I make shape display in black colour and background in white colour?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yashlin Naidoo
el 3 de Mayo de 2015
Comentada: Image Analyst
el 3 de Mayo de 2015
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
0 comentarios
Respuesta aceptada
Image Analyst
el 3 de Mayo de 2015
Just do
image(~circlePixels);
Or else change your colormap
colormap([1, 1, 1; 0, 0, 0]);
2 comentarios
Image Analyst
el 3 de Mayo de 2015
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Format and Export Documents and Graphics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!