How to reduce the number of colors in an image with OpenCV?

This subject was well covered on OpenCV 2 Computer Vision Application Programming Cookbook: Chapter 2 shows a few reduction operations, one of them demonstrated here in C++ and later in Python: #include <iostream> #include <vector> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> void colorReduce(cv::Mat& image, int div=64) { int nl = image.rows; // number of lines int nc … Read more

Text on image mouseover?

This is using the :hover pseudoelement in CSS3. HTML: <div id=”wrapper”> <img src=”http://placehold.it/300×200″ class=”hover” /> <p class=”text”>text</p> </div>​ CSS: #wrapper .text { position:relative; bottom:30px; left:0px; visibility:hidden; } #wrapper:hover .text { visibility:visible; } ​Demo HERE. This instead is a way of achieving the same result by using jquery: HTML: <div id=”wrapper”> <img src=”http://placehold.it/300×200″ class=”hover” /> <p … Read more

How to visualize a neural network

I adapted some parts to the answer of Milo from matplotlib import pyplot from math import cos, sin, atan class Neuron(): def __init__(self, x, y): self.x = x self.y = y def draw(self, neuron_radius): circle = pyplot.Circle((self.x, self.y), radius=neuron_radius, fill=False) pyplot.gca().add_patch(circle) class Layer(): def __init__(self, network, number_of_neurons, number_of_neurons_in_widest_layer): self.vertical_distance_between_layers = 6 self.horizontal_distance_between_neurons = 2 self.neuron_radius … Read more

Draw a rectangle in Golang?

The standard Go library does not provide primitive drawing or painting capabilities. What it provides is models for colors (image/color package) and an Image interface with several implementations (image package). The blog post The Go Image package is a good introduction to this. It also provides a capability to combine images (e.g. draw them on … Read more

How to remove all lines and borders in an image while keeping text programmatically?

Since no one has posted a complete OpenCV solution, here’s a simple approach Obtain binary image. Load the image, convert to grayscale, and Otsu’s threshold Remove horizontal lines. We create a horizontal shaped kernel with cv2.getStructuringElement() then find contours and remove the lines with cv2.drawContours() Remove vertical lines. We do the same operation but with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)