Changing color in matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
I've attached an image herewith. I want to change the color from green to red. Thanks.
채택된 답변
Voss
2023년 9월 28일
im = imread('xyz_converted.png');
im(:,:,[1 2]) = im(:,:,[2 1]); % swap the Red and Green channels
imshow(im)
댓글 수: 7
Walter Roberson
2023년 9월 29일
You can zip the tiff and attach the zip.
TIFF files can have 4 channels under several circumstances:
- They might have an alpha channel. Tiff with alpha can generally be converted to png, if you are careful about the imwrite()
- They might be CMYK TIFF -- CMYK support is an important reason why TIFF was designed (even if I rarely see CMYK TIFF in practice, as those are mostly used in publishing)
- The 4th (and possibly additional) channels might be addtional spectra, most commonly NIR (Near Infrared). If you have included infrared you should typically be working with the Hyperspectral Imaging Library, https://www.mathworks.com/help/images/hyperspectral-image-processing.html
- TIFF are one of the most common file formats for use with multiple "layers" of data, such as having views from the air together with information about roads and maybe about sewers and maybe about power lines and maybe about income... In particular, geotiff extension is often used for those kind of tiff images.
추가 답변 (2개)
Pratham Shah
2023년 9월 28일
I=imread("xyz_converted.png");
I(:,:,1)=I(:,:,2);
[m,n,~]=size(I);
I(:,:,2)=zeros(m,n);
imshow(I)
Catalytic
2023년 9월 28일
A = imread('xyz_converted.png');
[R,G,B] = imsplit(A);
B=cat(3,G, 0*R,0*B);
imshow(B)
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!