フィルターのクリア

How to add alpha channel to the image and convert that image into png format?

30 ビュー (過去 30 日間)
Hi i want to combine image with the alpha channel having 100%opacity no color it. and after some processing i have to remove the aplha channel .how to remove it can anyone help me to do.

採用された回答

Walter Roberson
Walter Roberson 2012 年 12 月 31 日
imwrite(RGBarray, filename, 'png', 'Alpha', ones(size(RGBarray,1),size(RGBarray,2)) )
When you imread(), use
[RGBdata, map, alpha] = imread(filename, 'png');
Note: this is specific to PNG files. A couple of other image formats handle Alpha this way, but some of the other image formats handle Alpha in other ways.
  6 件のコメント
goldensona
goldensona 2013 年 1 月 2 日
for image editing purpose, use superimposing or painting ,if i use photoshop to change it will destroy pixel value
Walter Roberson
Walter Roberson 2013 年 1 月 2 日
If you change the RGB array values of the image, then they are changed just like with photoshop.
You can display one image on top of another, but it does not sound like you want to do that.

サインインしてコメントする。

その他の回答 (2 件)

Image Analyst
Image Analyst 2012 年 12 月 31 日
I'm not sure exactly what you mean. Do you just want to put stuff in the overlay, like with functions plot(), line(), patch(), annotation(), etc. and be able to turn them on or off? Or do you want to save stuff you put in the overlay, say burned into the image and saved as a disk file with export_fig()? Or do you want to do what Walter suggested?
  31 件のコメント
goldensona
goldensona 2013 年 1 月 27 日
can any one tell about tampering localization capability ?
Walter Roberson
Walter Roberson 2013 年 1 月 28 日
Maybe, if it were defined. But it sounds like something that should be analyzed through theory (which is outside the scope of this forum), or else through experimentation.

サインインしてコメントする。


Jo
Jo 2018 年 3 月 7 日
編集済み: Jo 2018 年 3 月 7 日
If you need using TIFF format to add alpha channel, you can refer to this page: https://www.mathworks.com/help/matlab/ref/tiff-class.html#btqyn4b-3
The second example can solve your problem:
rgb = imread('example.tif');
numrows = size(rgb,1);
numcols = size(rgb,2);
alpha = 255*ones([numrows numcols], 'uint8');
data = cat(3,rgb,alpha);
t = Tiff('myfile.tif','w');
t.setTag('Photometric',Tiff.Photometric.RGB);
t.setTag('Compression',Tiff.Compression.None);
t.setTag('BitsPerSample',8);
t.setTag('SamplesPerPixel',4);
t.setTag('SampleFormat',Tiff.SampleFormat.UInt);
t.setTag('ExtraSamples',Tiff.ExtraSamples.Unspecified);
t.setTag('ImageLength',numrows);
t.setTag('ImageWidth',numcols);
t.setTag('TileLength',32);
t.setTag('TileWidth',32);
t.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
t.write(data);
t.close();
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 3 月 7 日
Right, but the original poster was interested only in PNGs.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by