필터 지우기
필터 지우기

How to converting RGBa (m x n x 4) .tif image to RGB (m x n x 3) .tif

조회 수: 48 (최근 30일)
Zander
Zander 2014년 3월 23일
댓글: Zander 2014년 3월 23일
After help on my previous question, I have found that some images I want to crop (using imcrop) have been converted to RGBa due to some previous operations in paint.net (I flattened the images but still can't remove the Alpha). I thought they might be cmyk and tried a conversion I found but this gave a weird reversed image so thus I am pretty sure I have RGBa.
Does anyone have any code to convert my images within my cropping function? I have spent hours searching but to no avail.
Many thanks

채택된 답변

Image Analyst
Image Analyst 2014년 3월 23일
Why can't you just do
% Extract only channels 1, 2, & 3.
rgbImage = rgbImage(:,:,1:3);
??? What do you mean you "Flattened" the image? Can you attach your image so we can try stuff?
  댓글 수: 2
Zander
Zander 2014년 3월 23일
I was using two layers (and hence some transparency) in Paint.net. Afterwards I 'flattened' it to remove the layers (the cause of it changing to RGBa). But it didn't remove that extra part of the image matrix.
I can't seem to attach the image properly as it is a .tif. I must seem like a real idiot!
I've changed the file name to include a . jpg and it seemed to attach ok. Just remove that bit.
Thanks
Zander
Zander 2014년 3월 23일
Just tried what you said... it worked!!!! I tried that before but being the noob I am, I was only extracting one channel at a time so came out as grayscale of one colour value.
You've saved my bacon! Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by