Images must contain fewer than 2^32 - 1 bytes of data

18 views (last 30 days)
I want to combine two images, with the following characteristics:
A: r,c = 51200,38497 uint16
B: r,c = 41505,38497 uint16
into
C: r,c = 92705,38497 uint16
The problem is that when I am trying to save it is not possible due to the following error:
Images must contain fewer than 2^32 - 1 bytes of data.
In addition, a strange thing is that if it is not possible to write C as a tif in 16bits why it is possible to read an image with the similar rows and collumns of C matrix?
Any ideas about the saving step?
  2 Comments
Matt J
Matt J on 20 Dec 2021
when I am trying to save it is not possible due to the following error:
What code did you use to save?
if it is not possible to write C as a tif in 16bits why it is possible to read an image with the similar rows and collumns
How do you know it is? What code did you use to read?
zbingos
zbingos on 20 Dec 2021
Imwrite and imread. I am trying now to follow Walter and Liu answers by setting correctly the tags in Geotiff.

Sign in to comment.

Accepted Answer

yanqi liu
yanqi liu on 20 Dec 2021
yes,sir,may be use TIFF object,such as
t = Tiff('myfile.tif','w');
write(t,your_image_data);
close(t);
  3 Comments
yanqi liu
yanqi liu on 21 Dec 2021
@Walter Roberson yes,sir,it is important on configure tiff writer,thanks
@zbingos may be use an example,such as
clc; clear all; close all;
% configure tiff
t = Tiff('myfile.tif','w8');
setTag(t,'ImageLength',10);
setTag(t,'ImageWidth',10);
setTag(t,'Photometric',Tiff.Photometric.RGB);
setTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
setTag(t,'BitsPerSample',16);
setTag(t,'SamplesPerPixel',3);
% make data
your_image_data = uint16(ones(10,10,3));
your_image_data(1,1,1:3) = 2^32 - 1;
% write data
write(t,your_image_data);
close(t);
% read and display
a = imread('myfile.tif');
a(1,1,1)
>> a(1,1,1)
ans =
uint16
65535
>>

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 20 Dec 2021
imread can read bigtiff. imwrite cannot write bigtiff. The link above shows how to write bigtiff.

Community Treasure Hunt

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

Start Hunting!