Crecimiento de dominios en metales y espumas
Sistema de adquisición de imágenes basado en una máquina linux y uno o varios escaners.
Se pretende entender la dinámica del crecimiento de granos en metales, mediante el estudio experimental del crecimiento de burbujas en espumas.
Este sistema presenta una dinámica similar al crecimiento de granos en metales, pero tiene la ventaja de que las burbujas crecen a una rapidez razonable y además es muy fácil obtener imágenes de éstas.
Luego de analizar este proceso de crecimiento, se obtienen datos reales con los cuales es posible el estudio teórico usando modelos matemáticos.
El experimento consiste en un sistema bidimensional formado por dos placas de vidrio que contienen en su interior una espuma jabonosa.
Descripción del sistema
Específicamente se entregará:
Ejemplos de implementaciones similares:
Medición del nivel de cobre en un convertidor el teniente usando
Software de procesamiento de imágenes
Image Measurement and Analysis Lab tnimage
ftp://entropy.brni-jhu.org/pub/unix (all Unix versions)
http://entropy.brni-jhu.org/tnimage.html (all versions)
ftp://entropy.brni-jhu.org/pub/dos/ (DOS version)
Ejemplo de filtros en burbujas pequeñas
Ejemplo de filtros en burbujas grandes
Conteo de granos
Tnimage puede usar un algoritmo de segmentación rápida, un algoritmo de red neuronal, o un algoritmo de diferencia espacial para identificar y contar objetos en una imagen. La elección del algoritmo a usar depende del tipo de objeto a contar.
Redes neuronales son preferibles para estructuras complejas, debido a que toman en consideración la estructura interna del objeto. Sin embargo éstas requieren el ajuste de tres parámetros (threshold, match weight, y mismatch weight) en vez de uno, de manera que puede ser difícil encontrar la mejor combinación de parámetros para discriminar en forma óptima entre estructuras similares.
Segmentación rápida es muy eficiente y rápida, pero es sólo adecuada para contar granos negros en un fondo claro. Los granos necesitan ser separados uno de otro en forma previa.
El algoritmo de diferencia espacial es también adecuado principalmente para pequeños objetos oscuros como granos, pero es mejor separando objetos que se tocan entre ellos.
Comparación de Métodos de Conteo de Granos
Procesamiento en modo BatchTnimage puede también ser usado en modo "batch" para operar en forma automática. Esto es útil para operaciones que consumen mucho tiempo o necesitan ser hechas en forma reiterada.
Crear primero una macro en tnimage y guardarla en disco duro.
El último comando en la macro debiera ser "quit" para asegurar que
tnimage salga al finalizar.
El comando ``messages(0)'' puede también ser usado para asegurar
que cualquier mensaje de error sea ignorado en vez de que el programa
se quede esperando por una respuesta, hay que asegurarse de que la
macro funcione bien primero.
La manera de ejecutar una macro es la siguiente:
Interfaz de línea de comandosEl editor de macros en tnimage puede también actuar como una interfaz de línea de comandos. Moviendo el cursor al final de la línea y presionando Shift-Enter o bien la tecla Ctrl-M causa que la línea sea ejecutada. Esto tiene la ventaja adicional de que una lista de comandos puede ser guardada en un archivo, para servir como documentación y para permitir que los mismos comandos sean ejecutados posteriormente. La ventana principal puede también ser iconificada y las imágenes pueden ser cargadas en ventanas individuales, de manera que la funcionalidad completa del programa puede ser obtenida sin el uso del ratón si se desea
FiltrosPerforms a convolution filter on the currently-selected image, or the selected screen region. The original image should be backed up before filtering it, in case you don't like the results.
For images greater than 8 bits/pixel, only the selected color planes are filtered. Color planes can be selected in the ``Config'' dialog box. Indexed-color images are temporarily converted to 24 bits/pixel before filtering, then converted back using the quantization method selected in the "Configure..." dialog.
In general, the kernel size should be close to the size of the features of interest. In particular, with Laplace edge enhancement, if the features are larger than 3 pixels across, a 3x3 or 9x9 kernel may actually make the image appear fuzzier, while a 5x5 kernel might dramatically sharpen the image. The amount of filtering can be adjusted from 1 to 100.
8.1.1 High-pass filter (Sharpening)Extracts only the highest spatial frequencies in the image. More low frequency components are saved if a larger 'kernel' is selected. If the image contains few high-frequency components, and too much sharpening was selected, the result may appear dark or black. This can be corrected by increasing the contrast of the image after filtering it.
8.1.2 Low-pass filteringLow-pass filtering eliminates sharp edges from the image, causing a blurring effect. The total intensity is unchanged, but is spread throughout the neighboring pixels.
8.1.3 Background subtractThis is similar to high-pass filtering except it removes only the lowest frequencies. This has the effect of removing uneven background in the image. As with high-pass filtering, it can make the image appear darker. Selecting a larger kernel removes less of the low frequencies, but will require much more processing time. A preferred method is to use the ``kernel multiplier''. Selecting a multiplier of 5 with a 3x3 kernel produces results similar to using a multiplier of 1 with a 15x15 kernel, but is many times faster. For this reason, it is recommended to set the kernel to 3x3 for background subtract.
It is possible to specify whether ``black'' or ``white'' pixels should be considered as the background. If it is set to ``white'', the image will generally get lighter in regions of unvarying pixel intensity. If the background value is ``black'', the image will get darker wherever the pixel intensity does not vary. This can be compensated for by increasing the contrast.
Background subtraction will also trash any text in the image.
See also Background flatten, remove low frequencies, and Rank leveling.
8.1.4 Background Flatten (de-trending)
This filter removes the largest-scale gradients from the image or selected region by measuring the average pixel value in each corner and then adding or subtracting a value to equalize the overall intensity. This could also be done manually, by creating a gradient region on the screen and adding the image to it (see Gradient fill ). However, the manual method is not 2-dimensional.
In contrast to Background Subtraction, this filter does not trash text. It differs from remove low frequencies in that it only removes large-scale gradients from the image.
See also Background subtract, remove low frequencies, Force background, Rank leveling.
8.1.5 Force background to fixed value
This filter is similar to the ``Remove low frequencies'' filter, except that instead of adding and subtracting values to remove gradients in the image, it multiplies dark and light areas by some factor to make the low-frequency background constant. This constant value can be adjusted by clicking on the ``Background value'' box.
The difference between this filter and removing low frequencies is that, with this filter, the intensity of any information hidden in a dark area will be more accurately preserved. This filter can be thought of as a cross between the ``maximize local contrast'' and ``Remove low frequencies'' filters.
Forcing the background to the 50% intensity value (e.g., 128 for 8-bit images) gives the best retention of the original intensity variation. Setting it to 100% (i.e., 255) would be useful if the high-frequency features (such as grains or spots) were of interest.
See also Background subtract, remove low frequencies, and Rank leveling.
Comparison of different methods of compensating for uneven background.
8.1.6 Noise filtering (median filtering)Median filtering removes extraneous pixels from the image. This is useful if the image contains noise which consists of little dots that are clearly outside the range of the other pixels. If a given pixel varies by more than a certain amount from the pixels around it, median filtering substitutes the median of the neighboring pixels, thereby eliminating noise from the image. The image is otherwise unaffected. The range in ± pixel value units, outside of which a value is to be considered noise, can be changed. A higher value results in less noise removal. Excessive noise filtering can make an image appear posterized. A setting of 0 will create a smoothing effect.
8.1.7 Laplace edge enhancementThis filter finds any edges in the image whose length is equal or greater than the kernel size. The edges are then increased in intensity while non-edge regions are eliminated. The effect on text is to create an outline of the text.
8.1.9 Edge detect | , -Detects and enhances edges in the image preferentially in the horizontal or vertical direction.
8.1.10 Sharpen | / - \Sharpens the selected region or image preferentially in the indicated direction, creating a `freeze-fracture' 3-D effect. This is particularly useful for images of biological specimens that have low contrast, since it highlights the overall shape of the cells.
8.1.11 Remove low frequenciesThis filter uses a combination of operations to subtract a blurred copy of the image from itself, thereby making the background perfectly flat. The effect is about halfway between Background Subtract, which only removes the very low spatial frequencies, and High Pass, which enhances the high frequencies. Selecting a 3x3 kernel removes all but the highest frequencies, while a 15x15 kernel has a less harsh effect. The effect can be made even more gentle by specifying a kernel multiplier of 2 or more.
See also Background flatten, Background subtract, Force background, and Rank leveling.
8.1.12 Background subtraction by rank levelingRank leveling subtracts background gradients rapidly by assuming that the features of interest are small in size (less than 10×10 pixels). Subtracting nearby background pixels from the feature pixels achieves a very localized background flattening. Features larger than 10x10 will also be attenuated.
``Background level'' must be set correctly, otherwise the result will be garbage. For example, if the features are dark on a light background, background level must be set to ``white''.
This filter only works for grayscale images. Other settings including kernel size, range, and amount of filtering, are ignored.
As with ``background subtract'', it is usually necessary to adjust the contrast after filtering with rank level filter, because the image will get lighter or darker depending on the setting of ``background level''.
See also Background flatten, Background subtract, Force background, and Remove Low Frequencies.
8.1.13 User-definedPerforms a convolution filtering using a user-defined filter. This filter should be a text file with the folowing characteristics:
Example This 5×5 filter will enhance vertical edges.
8.1.14 EngraveFilters the image by converting edges to shadows so that the image resembles an engraved outline. Uses a threshold value to determine the pixel intensity value at which the outline is to be drawn.
8.1.15 Spatial differenceFilters image using a spatial differencing filter. This has the effect of separating closely-spaced objects so that there is a clear boundary between them. This is useful in preprocessing images before performing densitometry or grain counting. Uses a `size' parameter which determines the area over which the differencing will be performed for each pixel. A larger size will accentuate larger objects, and will have more noise immunity, but takes more processing time. Currently only works on monochrome images.
8.1.16 Multiplicative SobelThis experimental filter is similar to the Sobel filter (Sec.8.1.8) except that the differences are multiplied to each pixel rather than added. It produces a strongly non-linear effect of enhancing details in the image. Only works on monochrome images.
8.1.17 Maximize local contrast
This filter increases the contrast at each point in the image to the maximum possible value with respect to its neighbors. This is useful for images in which details are obscured in large dark or light areas. Increasing the contrast in the overall image would make these faint features visible, but at the expense of washing out all detail in other areas. Maximizing the contrast locally allows details in both light and dark areas to be viewed simultaneously. See Sec.
For example, in the mammogram shown below, in the left panel (A), some of the details in the mammogram are visible, while others are obscured in a dark area. After maximizing the local contrast, the details of the vascularization are easily discernable, and even the subtle gradations in the white background area are also clearly visible (B).
Maximizing local contrast.
The degree of contrast enhancement can be selected in the clickbox labeled ``Local contrast scale''. This value is the area over which the contrast will be measured for each pixel. A smaller value gives greater enhancement of fine details, while a large value only removes gentle background gradients. An excessively large value, however, can create artifacts. See sec. 9.12 for another example.
8.1.18 Adaptive maximize local contrastThis filter is similar to the ``Maximize local contrast'' filter, except that the contrast factor is calculated ``adaptively''. This makes it much faster. However, the results are sometimes not as good. The adaptation or ``decay factor'' can be adjusted.
8.1.19 Adjustable parameters
8.1.20 KernelThe kernel is the number of pixels used in calculating a pixel in the new image. The processing time needed increases with the square of the kernel size.
8.1.21 Kernel multiply factorA kernel multiply factor permits arbitrarily large kernel without an increase in computation time. This is possible because usually only a small sample of the surrounding pixels are really needed to calculate the new pixel value. For most types of filters, a 3x3 kernel with a kernel multiplier of 3 gives the same results as a 9x9 kernel, but is 3 times faster. For sharpening and blurring, this doesn't work, and the factor is automatically set to 1.
8.1.22 Amount of filteringThe amount of filtering applied to the image, from 1 to 100 (maximal filtering).
Effect of some different filters. The original is an image of the Horsehead Nebula.
Grain counting and pattern recognition
Tnimage can use the quick segmentation algorithm, a neural network algorithm, or a spatial differencing algorithm to identify and count objects in an image. The choice of which algorithm to use will depend on the pattern to be counted. Neural networks are preferable for complex patterns, since they take the internal structure of the pattern into account. However, neural networks require the adjustment of 3 parameters (threshold, match weight, and mismatch weight) instead of one, so it can be tricky to find the best combination of parameters to optimally discriminate between similar patterns.
Quick segmentation is extremely efficient and fast, but is only suitable for counting black grains on a light background. The grains need to be already separated from each other.
The differencing algorithm is also suitable mainly for small dark objects like grains, but is better at separating objects that touch each other.
The neural network algorithm is a modified and greatly simplified version of a hierarchical neural network. With appropriate threshold values, it is possible to count grains or any other pattern such as cells, faces, etc., in the presence of other potentially-interfering objects. To illustrate, we will count occurrences of the letter ``x'' in a simplified image.
The left panel below shows the original image, a combination of x's, y's and z's. The pattern recognition process subtracts pixels that are part of the pattern (in this case the `x's), while tye `y' and `z' are unaffected. This subtraction also allows any patterns obscured by the pattern to be identified on a subsequent pass.
Pattern recognition in tnimage.
Counting patterns with neural network method
8.12.1 Grain counting using neural network method
8.12.2 Grain counting using segmentation and differencing methods
8.12.3 Notes on Pattern counting
8.12.4 Possible problems with Grain and Pattern counting
WARNING: Measured grain sizes will be different depending on the method and parameters used. Users should verify that the results obtained are consistent with their expectations.
Size distribution using quick segmentation
Here is an example of an astronomical image after analysis by the quick segmentation algorithm. The threshold was set to 0.8 so that only the larger stars are counted. Each star that was counted is automatically labeled with its relative size. The size of a given object depends on the threshold and will be larger if the threshold is smaller, because more pixels are present in the distance matrix which is used to find grains. The grain counting dialog box is shown at right.
The size distribution graph (not shown) usually follows
Recommended Threshold and Weight values for neural network method
Note: These values should be considered as starting points only. Different images will need different thresholds and mismatch weights.
Example of neural network grain counting:
Below is an example of neural network grain-counting of a moderately-difficult image illustrating some of the steps that may be necessary to obtain the most accurate counts. Panel A shows the original image, which contains several grains that are out of focus or clumped together, as well as some grains that are sharply focused, and a darker, out-of-focus blue cell in the center, which could be difficult to distinguish from the two faint grains on top of it. Under some conditions, the cell could even be misidentified as a large clump of grains. The image was converted to grayscale (B) and the grains were enhanced (by clicking on ``Enhance grains''), producing C, which is more easily analyzed. Using the default threshold value of 0.5 and Match and Mismatch weights of 1 and -0.05, however, caused a number of extraneous points to be counted as grains (D). This occurred because the filtering process also increased the noise slightly. Changing the mismatch weight to -0.15 solved the problem, and the program counted the number of grains as 64, the correct number (E).
Batch mode processingTnimage can also be run in ``batch'' mode for unattended operation. This is useful for operations that are time-consuming or need to be done every day. A cron-like utility or (for the DOS version) a DOS command scheduler such as tnshell (available from the author) can be used to automatically carry out any sequence of operations at (for example) 3 a.m. on Thursdays or to automatically load a series of images before you come to work.
Procedure: Create a macro in tnimage and save it to disk. The last command in the macro should be ``exit'' to ensure tnimage quits when finished. The command ``messages 0'' can also be used to ensure that any error messages are ignored instead of causing the program to wait for an acknowledgment (Make sure the macro works before using this).
Command line interfaceSome users find it more convenient to type commands than select items from the mouse. The macro editor in tnimage doubles as a command-line interface. Moving the cursor to the end of a line and hitting < Shift-Enter > or the < Ctrl-M > key causes a single line to be executed. This has the additional advantage that a list of commands can be saved in a file, providing documentation and enabling the same commands to be executed later. The main window can also be iconified and images loaded into individual windows, so that complete functionality is obtained without use of a mouse if desired. For a complete list of commands, see Macro Commands (Sec. 14).
14.3 Macro Programming GuideHere is a brief tutorial on some of the finer points on creating useful macros. In general a macro should reset the program to its original state. If a macro does something different the second time it is executed, the cause is almost always a failure to reset the original conditions. In a real macro, you should also always execute ``select_image'' or ``open'' first to make sure the operation is performed on the correct image.
¯ Line # ¯ Command
Note: the words ``Line #'' and ``Command'' and the numbers 1,2, and 3 are not part of the macro. In this example, the macro would consist of only 3 words (``beep''), one on each line.
¯ Line # ¯ Command
Executing ``test.macro'' should cause a total of 4 beeps. A macro must never call itself - this would cause an infinite loop.
¯ Line # ¯ Command
Line 1 - Prompts you for a filename each time
Line 2 - Resets default file format to 0 (TIF). If this line is omitted, the file format would default to the original format of each image.
Line 4 - Saves the image in TIFF format. Don't forget to rename the file extension to TIFF later.
Line 5 - Resume error messages
Line 6 - Unconditional loop back to line 1. Press ESC to stop.
¯ Line # ¯ Command
dos ren *.gif *.tif
¯ Line # ¯ Command
Line 1: The pixel interaction mode is set to 1 (overwrite) in case a previous operation changed it.
Line 2: All 4 parameters (x offset, y offset, x size, and y size) must be given. Otherwise, if the macro was executed again, the default parameters would be 1,1,1,1 because of line 4. This would cause the image to be placed at (1,1) and then subtracted from itself, giving solid black.
Line 3: The pixel interaction mode is set to 5 (subtract). It is usually helpful to change the screen background color to 0 (black) before doing this.
Line 4: Load the image to subtract.
Line 5: Reset the pixel interaction mode to overwrite.
Line 6: Increase the intensity by a factor of 1.85.
¯ Line # ¯ Command
Line 2: Lighten the image by 5 intensity units.
Line 3: Add the corresponding region from image #2.
Line 4: Increase the red contrast by 1.23 fold.
Line 5: Subtract 5 intensity units from the selected region.