How do I make shape display in black colour and background in white colour?
조회 수: 2 (최근 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
댓글 수: 0
채택된 답변
Image Analyst
2015년 5월 3일
Just do
image(~circlePixels);
Or else change your colormap
colormap([1, 1, 1; 0, 0, 0]);
댓글 수: 2
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!