Borrar filtros
Borrar filtros

How to fill rectangle with same color in image?

2 visualizaciones (últimos 30 días)
Junwon Park
Junwon Park el 15 de Jun. de 2018
Comentada: Image Analyst el 18 de Jun. de 2018
Hi,
I want to fill rectangle with same color such as bellow image. So, i recognition it to rectangle or square.
Please, let me know.
Thanks.
  1 comentario
Image Analyst
Image Analyst el 18 de Jun. de 2018
I don't understand.
The image has TWO colors. Which do you want?
Or do you want the average color of the black and red (like a dark red)?
"I want to fill rectangle" Fill WHAT rectangle?
And what does "recognition it to rectangle or square" mean? You already said that it was a rectangle. Do you just want to see if the image height equals the image width, and it if is, declare, say with msgbox() or helpdlg(), that the image is square?
Read this link and then clarify if you still need more help, because we're totally confused.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 15 de Jun. de 2018
Editada: KSSV el 15 de Jun. de 2018
I = imread('target1.png') ;
I1 = rgb2gray(I) ;
[y,x] = find(I1) ;
R = I(:,:,1) ; G = I(:,:,2) ; B = I(:,:,3) ;
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
[X,Y] = meshgrid(x0:x1,y0:y1) ;
idx = sub2ind(size(I1),Y(:),X(:)) ;
I2 = I ;
C = [mean(R(idx)) mean(G(idx)) mean(B(idx))] ;
for i = 1:3
T2 = I2(:,:,i) ;
T2(idx) = C(i) ;
I2(:,:,i) = T2 ;
end
imshow(I2)

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by