Instead of read the whole image first and then take part of feature, but only read this feature part of the image from the beginning, how to do it? Using fread function?

2 views (last 30 days)
How to read the feature part of the image (without white color area)? Izit using fread function?
  2 Comments
Jan
Jan on 22 May 2017
The question is not clear. What is "the feature part" and how is it defined in your code? In which format is the image saved? Whyt is the benefit of reading the image partially? Most likely it will be much faster to perform the cropping when the image is imported into the RAM. So why do you want to apply a very complicated import function?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 15 Jun 2017
No, those are JPEG images. There is no provided way to read only part of a JPEG image.
Looking around, I find a reference that claims that libjpeg supports reading JPEG images line by line. Considering that JPEG are divided into blocks, I suspect that would involve reading and decoding information and throwing out most of it -- either that or perhaps it only supports reading groups of 8 lines at a time. Either way, it certainly does not support reading only irregular parts of an image.
  2 Comments
Walter Roberson
Walter Roberson on 16 Jun 2017
No, PNG files have no way of handling this kind of situation.
TIFF files are permitted to be written in "tiles" that can be read separately -- so for example you might happen to know that there are three tiles between the left edge of the image and the left side of the leaves around the stem, below the petals and above the leaves. If you happened to know that, and if it happened that everything aligned just right, then with TIFF images you could skip those tiles as you read the others. This would typically be slower than reading the whole thing in this circumstance, as you would need to be going back and forth between MATLAB and libtiff all the time instead of staying inside libtiff to read the entire image.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!