Image processing and analysis, layers on image
14 ビュー (過去 30 日間)
古いコメントを表示
I am building an image for analysis on matlab that has a bunch of different layers that i have been overlapping using the image() function, but when i go to export the image using saveas() the resolution is the same as the preview window and not good for analysis. is there a way to build the image layers and export it in the native resolution of the layers?
0 件のコメント
採用された回答
DGM
2022 年 3 月 27 日
It depends what exactly you're doing with image(). If you want to compose an image from many similarly-sized images, you should be able to do that without having to rely on trying to capture the figure contents and all the problems that entails.
If you're just composing the layers by setting the 'AlphaData' property of the image objects, then you can do that by multiplication
BG = imread('peppers.png');
FG = fliplr(BG);
alph = 0.5;
R = FG.*alph + BG.*(1-alph);
imshow(R)
If your images are not the same size, then the composition becomes more complicated. You might have to elaborate on what exactly you're doing.
2 件のコメント
DGM
2022 年 3 月 27 日
編集済み: DGM
2022 年 3 月 27 日
Capturing things from figures is tantamount to taking a screenshot. For image processing, consider figures as visualization tools, not as composition tools. Other people may feel otherwise, but that's my perspective.
As I said, I would compose the image by itself. You could use a rudimentary approach like that described above. That would be simple enough if your alpha is scalar. Just work from the bottom image up.
You could do other things depending on what you're dealing with. If your images have full (2000x2000) alpha as a separate array, you could still do the same, or you could use something like MIMT replacepixels(), which just makes the process neater and less dependent on numeric class.
% create some images
BG = imread('peppers.png');
FG1 = imtweak(BG,'lchuv',[1 1 0.25]); % imtweak is also MIMT-only
FG2 = imtweak(BG,'lchuv',[1 1 0.50]);
FG3 = imtweak(BG,'lchuv',[1 1 0.75]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943054/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943059/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943064/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943124/image.png)
% some alpha
a1 = imread('pgrad1.png');
a2 = imread('pgrad2.png');
a3 = imread('pgrad3.png');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943069/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943074/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943079/image.png)
% compose the images
outpict = replacepixels(FG1,BG,a1);
outpict = replacepixels(FG2,outpict,a2);
outpict = replacepixels(FG3,outpict,a3);
imshow(outpict)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/943084/image.png)
In this example, the layers are ordered BG, FG1, FG2, FG3, with BG on the bottom and FG3 on the top. The composition follows from the base layer and works up to the top.
その他の回答 (1 件)
Image Analyst
2022 年 3 月 27 日
@DGM is correct. Deal with the actual images, not screen captures. You can get alpha transparencies by adding in a fraction of the overlay image. You can also add in many other images just make sure you convert to double or else if they're uint8, they will clip at 255. So convert to double, add up all the various weighted images, and then call uint8(rescale(rgbImage, 0, 255)) to make it back into a uint8 RGB image.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!