Based on the material in the last section, we continue to explore color detection. In the previous patch, we do not know exactly which pixel in the window we are checking. To provide a visual feedback, we can use a small square to indicate the position. We also remove most of the number boxes to enhance performance. One of the easy ways to improve performance of a Pure Data patch is to remove the unnecessary graphical interface units, such as bang, number box, and toggle. It takes CPU time for Pure Data to update those items in the patch window. The Color004.pd
patch is a working version for performing color detection. The result will be the final number box from the colorDistance
abstraction:
The patch uses the same mapping logic to map the range between 0
and 1
to the width of 10.66 units and the height of 8 units. The center of the white square is the pixel we use for checking:
Note that when you click on the toggle to store color, the resulting number box reduces...