15
I want the user to trace a line in a biometric image and make an automatic count of "black parts" of the digital that this line crossed.
I have no idea which tool to use and where to start... Someone has some way?
It is for web environment...
15
I want the user to trace a line in a biometric image and make an automatic count of "black parts" of the digital that this line crossed.
I have no idea which tool to use and where to start... Someone has some way?
It is for web environment...
1
You can use php itself to do this, you don’t need to use javascript if you don’t want, I made an example manipulating and creating an image of only two colors that I used for testing (black and white) and modelling it on html itself again with a scale of 10 pixels by 10 pixels.
<style>
.container {
height: 10px;
width: 100px;
}
.bloco {
width: 10px;
height: 10px;
display: block;
float: left;
}
.preto {
background: black;
}
.branco {
background: white;
}
</style>
<?php
$image = imagecreatefrompng('biometria.png'); //aqui é o caminho da imagem
$IniX = 0; //inicio largura
$FimX = 10; //dimensão de largura da imagem
$IniY = 0; //inicio altura
$FimY = 10; //dimensão de altura da imagem
$codigoCorPreta = 0; //se for rgb(0,0,0) é zero. porém nem todo preto é realmente preto.
$pxPreto = 0; //qtd. de pixels pretos zerada inicialmente
for ($y = $IniY; $y < $FimY; $y++ ) {
echo '<div class=container>'; //container para envolver cada linha horizontal
for($x = $IniX; $x < $FimX; $x++ ) {
$value = imagecolorat($image, $x, $y);
if ($value === $codigoCorPreta){
//se a cor no pixel atual for totalmente preta vai entrar aqui mas tbm poderia ser '($value < 9000000)' por exemplo para captar mais tons de preto.
$cor = 'preto';
$pxPreto++; //incrementa qtd de pixels pretos
} else {
$cor = 'branca';
}
echo "<div class='bloco {$cor}'></div>"; //cria uma div de 10x10 simulando 1 pixel com a cor branca ou preta.
}
echo '</div>';
}
echo "Total de pixels pretos: {$pxPreto}"; //aqui imprime a quantidade total de pixels pretos que foi percorrido.
?>
This is the image I used as an example to "biometria.png"
And this was the result obtained in HTML generated by PHP:
"Real tests" on a biometric image:
In this test I used if ($value < 9000000){
to check if "black or not"
in order to cover more shades of black and not only rgb(0,0,0)
Results:
The value I used ($value < 9000000)
was only for testing, I can’t tell you if this would be a "plausible" value to identify black tones.
If the image you want to work on is jpg
you must change the function imagecreatefrompng
for imagecreatefromjpeg
.
0
Taking as example the Imagecolorpicker project(https://github.com/Skarabaeus/ImageColorPicker/).
https://github.com/Skarabaeus/ImageColorPicker/blob/master/src/ImageColorPicker.js line80
... .bind("mousemove", function(e){
...
/*Aqui coloque sua lógica - (toda vez que q o pixel for da cor */
/* que vc determinar incrementa um contador). */
...
});...
Browser other questions tagged php javascript
You are not signed in. Login or sign up in order to post.
If you do not know what technology to use, it is difficult to obey help here. From what you said, da para fazer isso usando canvas. Just sequentially scroll through all the pixels on the line and check when there is a total switch from white to black.
– mau humor
There are some approaches that may be useful, but that will depend on the image quality. My intuition says you should : 1) convert the image to grayscale (to avoid working with RGB); 2) apply a filter for edge extraction (has a simple algorithm in this my answer); 3) segment the region under the line (ignore all other image); 4) count the groupings of black pixels (like a region growth).
– Luiz Vieira
By the way, you have a [mcve] in Javascript that does the part of displaying the digital image (any, example) and allows you to trace the line in it? If you do, share it, which will make it much easier for someone to help you more directly/completely.
– Luiz Vieira
Another thing: this seems to be feasible in Javascript. Thus, you can show the result to the user without having to make requests to the server. I try this way before trying in PHP.
– Luiz Vieira
What do you want a biometric reading system? If it is, based on lines, it will never be necessary, because it can have repetition. The idea is not to draw lines but to map points at the points of the strokes and intersections of the drawing, where there is a black record. And then capture these points again.
– Ivan Ferrer
Like in this image example.
– Ivan Ferrer
Try to do something thereby. or thereby or thereby
– Ivan Ferrer
Here has a book that can help you
– Ivan Ferrer
Related
– Guilherme Pressutto
More related with subject.
– Ivan Ferrer
And if you convert the image to ASCII and find the pattern from there?
– Renato Junior