# mmdchickparts
Classify chicken parts in breast, legs+tights and wings

## Description

The input image is a gray-scale image of many different chicken parts. The purpose is to classify them in breast, legs+tights, tights and wings.

## Demo Script

### Reading

The input image is read.

    >>> a = mmreadgray('chickparts.tif');

    >>> mmshow(a);

a |

### Thresholding and labeling

Convert to binary objects by thresholding and then labeling the objects.

    >>> b = mmcmp(a,'>=', uint8(100));

    >>> mmshow(b);

    >>> c = mmlabel(b);

    >>> mmlblshow(c,'border');

b | c,'border' |

### Area measurement

Measure the area o each object and put this value as the pixel object value. For displaying purpose, overlay the background as red in the right image below.

    >>> d = mmblob(c,'area');

    >>> mmshow(d);

    >>> mmshow(d, mmcmp(d,'==',0));

d | d, mmcmp(d,'==',0) |

### Select the wings and tights

The wings are detected by finding objects with area 100 and 2500 pixels. The tights are selected as connected objects with area between 2500 and 5500 pixels.

    >>> wings = mmcmp( uint16(100),'<=',d, '<=', uint16(2500));

    Warning: Converting input image from int32 to uint16.
    Warning: Converting input image from int32 to uint16.

    >>> mmshow(wings);

    >>> tights = mmcmp( uint16(2500),'<',d, '<=', uint16(5500));

    Warning: Converting input image from int32 to uint16.
    Warning: Converting input image from int32 to uint16.

    >>> mmshow(tights);

wings | tights |

### Select the legs and breast

The legs+tights have area larger than 5500 and smaller than 8500 pixels and the breast is the largest connected object with area larger than 8500 pixels

    >>> legs = mmcmp( uint16(5500), '<', d, '<=', uint16(8500));

    Warning: Converting input image from int32 to uint16.
    Warning: Converting input image from int32 to uint16.

    >>> mmshow(legs);

    >>> breast = mmcmp( d,'>', uint16(8500));

    >>> mmshow(breast);

legs | breast |

### Final display

Overlay the contour of the detected parts over the original image

    >>> mmshow(a, mmgradm(wings), mmgradm(tights), mmgradm(legs),mmgradm(breast));

a, mmgradm(wings), mmgradm(tights), mmgradm(legs),mmgradm(breast) |

[`mmdcells`] [Up] [`mmdconcrete`] |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.