# \donttest{
############################################################################
#Obtendo o numero de ovos em uma folha
############################################################################
#Carregar imagem de exemplo
im=read_image(example_image(2))
##mostrar imagem
plot_image(im)
#Selecionando o melhor indice para a segmentacao da folha
r=gray_scale(im,method = "r",plot=TRUE)
g=gray_scale(im,method = "g",plot=TRUE)
b=gray_scale(im,method = "b",plot=TRUE)
#O canal azul possibilita maior contraste
#O limiar pode ser um valor escolhido aleatoriamente (por exemplo: 0.6)
MatrizSegmentada=segmentation(b,threshold = 0.39,fillHull = TRUE,
selectHigher = FALSE,plot=TRUE)
im2=extract_pixels(im,target =MatrizSegmentada,valueTarget =1,
valueSelect = c(0,0,0),plot=TRUE )
#Selecionando o melhor indice para a segmentacao dos ovos
r=gray_scale(im2,method = "r",plot=TRUE)
g=gray_scale(im2,method = "g",plot=TRUE)
b=gray_scale(im2,method = "b",plot=TRUE)
#O canal Azul proporciona melhor segmentacao
#O limiar pode ser um valor escolhido aleatoriamente (por exemplo: 0.6)
MatrizSegmentada2=segmentation(b,threshold = 0.50,fillHull = TRUE,
selectHigher = TRUE,plot = TRUE)
Medidas=measure_image(MatrizSegmentada2)
Medidas$ObjectNumber
#Ver a mascara sobre os ovos na foto
im3=mask_pixels(im,MatrizSegmentada2==1,plot=TRUE)
# }
Run the code above in your browser using DataLab