• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

save image to be used as array 8 bit

Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Hi there,

I have to save 8 bit images with the following structure when converted to an array:

 

array([[[ 60, 124, 150, 255],
        [ 60, 124, 150, 255],
        [ 60, 124, 150, 255],
        ...,

 

But when I save as png 8 bit I obtain

 

array([[[115, 124,  67],
        [118, 127,  70],
        [122, 131,  76],
        ...,

 

Thank you!

TOPICS
macOS

Views

208

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Obviously, they are 2 different examples. I would need the 255 at the end of each single array!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

I have no idea how you are going from Photoshop to PNG to this array data, but that is not the form used by PNG. In particular, PNG-8 does not contain a 2D array of RGB or RGBA values, one per pixel; that would be impossible, since you have only 8 bits per pixel. Rather it stores a 2D array of indexes. Each index looks up an RGB value (not RGBA). A PNG-8 file may additionally include a tRNS chunk, which gives transparency values for specific index values.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

LATEST

I used Python with PIL:

image_raw = np.array(Image.open('./image'))

 

Btw, it works with PNG-8 save for web.

 

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines