Read and Analyze Image Files

This example shows how to create a datastore for a collection of images, read the image files, and find the images with the maximum average hue, saturation, and brightness (HSV). For a similar example on image processing using the mapreduce function, see Compute Maximum Average HSV of Images with MapReduce.

Identify two MATLAB® directories and create a datastore containing images with .jpg, .tif, and .png extensions in those directories.

For each image in the collection, read the image file and calculate the average HSV values across all of the image pixels. If an average value is larger than that of a previous image, then record it as the new maximum (maxAvgH, maxAvgS, or maxAvgV) and record the corresponding image data (dataH, dataS, or dataV).