writeEncodedStrip
Write data to specified strip
Description
writeEncodedStrip(
writes t,stripNumber,imageData)imageData to the strip specified by
stripNumber to the TIFF file associated with the
Tiff object t.
Examples
Read two strips from a TIFF file and write them to a new TIFF file in different positions.
Open a TIFF file with image data in stripped layout, get the image data and the number of strips in the image.
tr = Tiff('peppers_RGB_stripped.tif','r'); imageR = read(tr); nStrips = numberOfStrips(tr)
nStrips = 6
Read the 2nd and 5th strips of the image.
stripTwo = readEncodedStrip(tr,2); stripFive = readEncodedStrip(tr,5);
Create a Tiff object for a new file and copy the image and tag information from the first file.
tw = Tiff('write_strip.tif','w'); tagstruct.ImageLength = getTag(tr,'ImageLength'); tagstruct.ImageWidth = getTag(tr,'ImageWidth'); tagstruct.Photometric = getTag(tr,'Photometric'); tagstruct.RowsPerStrip = getTag(tr,'RowsPerStrip'); tagstruct.BitsPerSample = getTag(tr,'BitsPerSample'); tagstruct.SamplesPerPixel = getTag(tr,'SamplesPerPixel'); tagstruct.PlanarConfiguration = getTag(tr,'PlanarConfiguration'); setTag(tw,tagstruct); write(tw,imageR)
Write stripFive in the position for strip number 2 and stripTwo in the position for strip number 5.
writeEncodedStrip(tw,2,stripFive); writeEncodedStrip(tw,5,stripTwo);
Read and display the new image next to the original image.
imageW = read(tw); subplot(121); imshow(imageR); title('Original Image') subplot(122); imshow(imageW); title('Strips Shuffled Image')

Close the Tiff objects.
close(tr); close(tw);
Read two strips from a YCbCr TIFF file and write them to a new TIFF file in different positions.
Open a TIFF file containing YCbCr image data in stripped layout, get the image data and the number of strips in the image.
tr = Tiff('peppers_YCbCr_stripped.tif','r'); [Yr,Cbr,Crr] = read(tr); nStrips = numberOfStrips(tr)
nStrips = 6
Read the 2nd and 5th strips of the image.
[Y2,Cb2,Cr2] = readEncodedStrip(tr,2); [Y5,Cb5,Cr5] = readEncodedStrip(tr,5);
Create a Tiff object for a new file and copy the image and tag information from the first file.
tw = Tiff('write_strip.tif','w'); tagstruct.ImageLength = getTag(tr,'ImageLength'); tagstruct.ImageWidth = getTag(tr,'ImageWidth'); tagstruct.SampleFormat = getTag(tr,'SampleFormat'); tagstruct.Photometric = getTag(tr,'Photometric'); tagstruct.RowsPerStrip = getTag(tr,'RowsPerStrip'); tagstruct.BitsPerSample = getTag(tr,'BitsPerSample'); tagstruct.SamplesPerPixel = getTag(tr,'SamplesPerPixel'); tagstruct.YCbCrSubSampling = getTag(tr,'YCbCrSubSampling'); tagstruct.Compression = getTag(tr,'Compression'); tagstruct.PlanarConfiguration = getTag(tr,'PlanarConfiguration'); setTag(tw,tagstruct); write(tw,Yr,Cbr,Crr)
Write strip number 5 in the position for strip number 2 and strip number 2 in the position for strip number 5.
writeEncodedStrip(tw,2,Y5,Cb5,Cr5); writeEncodedStrip(tw,5,Y2,Cb2,Cr2);
Read and display the Y component of the new image next to the original image.
[Yw,Crw,Cbw] = read(tw); subplot(121); imshow(Yr); title('Original Image (Y)') subplot(122); imshow(Yw); title('Strips Shuffled Image (Y)')

Close the Tiff objects.
close(tr); close(tw);
Input Arguments
Tiff object representing a TIFF file. Use the Tiff function to create the object.
Strip number, specified as a positive integer. Strip numbers are one-based numbers.
Example: 15
Data Types: double
Image data, specified as a numeric array.
If
imageDatahas more number of bytes than the size of the strip, thenwriteEncodedStripissues a warning and truncates the data.If
imageDatahas fewer number of bytes than the size of the strip, thenwriteEncodedStripsilently pads the strip.
To determine the size of the strip, view the value of the
RowsPerStrip tag.
Data Types: double
Luma component of the image data, specified as a two-dimensional numeric array.
Data Types: double
Blue-difference chroma component of the image data, specified as a two-dimensional numeric array.
Data Types: double
Red-difference chroma component of the image data, specified as a two-dimensional numeric array.
Data Types: double
Algorithms
This function corresponds to the TIFFWriteEncodedStrip function
in the LibTIFF C API. To use this function, you must be familiar with the TIFF
specification and technical notes. View this documentation at LibTIFF - TIFF Library and Utilities.
Version History
Introduced in R2009b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)