How can I change color of a circle?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Netanel Katash
el 28 de Oct. de 2021
imageSizeX = 256;
imageSizeY = 256;
[Imagecolumns, Imagerows] = meshgrid(1:imageSizeX, 1:imageSizeY);
Right_X = imageSizeX / 1.25;
Right_Y = imageSizeY / 2;
Left_X = imageSizeX / 5;
Left_Y = imageSizeY / 2;
radius = 15;
circlePixels = (Imagerows - Right_Y).^2 ...
+ (Imagecolumns - Right_X).^2 <= radius.^2;
circlePixels1 = (Imagerows - Left_Y).^2 ...
+ (Imagecolumns - Left_X).^2 <= radius.^2;
x = imshow(circlePixels|circlePixels1);
colormap([0.6 0.6 0.6 ; 0.3 0.3 0.3]);
axis square;
How can I change the color of one circle?
0 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Oct. de 2021
imageSizeX = 256;
imageSizeY = 256;
[Imagecolumns, Imagerows] = meshgrid(1:imageSizeX, 1:imageSizeY);
Right_X = imageSizeX / 1.25;
Right_Y = imageSizeY / 2;
Left_X = imageSizeX / 5;
Left_Y = imageSizeY / 2;
radius = 15;
circlePixels = (Imagerows - Right_Y).^2 ...
+ (Imagecolumns - Right_X).^2 <= radius.^2;
circlePixels1 = (Imagerows - Left_Y).^2 ...
+ (Imagecolumns - Left_X).^2 <= radius.^2;
x = imshow(circlePixels + 2*circlePixels1, []);
colormap([0.6 0.6 0.6 ; 0.3 0.3 0.3; 1 0 0]);
axis square;
Más respuestas (1)
yanqi liu
el 28 de Oct. de 2021
Editada: yanqi liu
el 29 de Oct. de 2021
clc; clear all; close all;
imageSizeX = 256;
imageSizeY = 256;
[Imagecolumns, Imagerows] = meshgrid(1:imageSizeX, 1:imageSizeY);
Right_X = imageSizeX / 1.25;
Right_Y = imageSizeY / 2;
Left_X = imageSizeX / 5;
Left_Y = imageSizeY / 2;
radius = 15;
circlePixels = (Imagerows - Right_Y).^2 ...
+ (Imagecolumns - Right_X).^2 <= radius.^2;
circlePixels1 = (Imagerows - Left_Y).^2 ...
+ (Imagecolumns - Left_X).^2 <= radius.^2;
bw = circlePixels|circlePixels1;
L = bwlabel(bw);
figure; imshow(label2rgb(L));
colormap([0.9 0.2 0.1 ; 0.6 0.6 0.6 ; 0.3 0.3 0.3]);
axis square; axis off;
% gen set color, such as red and green
im1 = 0.6*255*ones(size(bw));
im2 = 0.6*255*ones(size(bw));
im3 = 0.6*255*ones(size(bw));
% red
im1(L==1) = 255; im2(L==1) = 0; im3(L==1) = 0;
% green
im1(L==2) = 0; im2(L==2) = 255; im3(L==2) = 0;
im = uint8(cat(3, im1, im2, im3));
figure; imshow(im, []);
Ver también
Categorías
Más información sobre Polar Plots 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!