How to mix two images in loop with 10%step.
1 view (last 30 days)
Show older comments
I want to mixed two pics in mat (A and B) with 10% step. It will create a 10 pics. It can be code like this. But I would like to write it down like loop, so it looks better.
clear all, close all
load('OBRAZKY/tvare.mat')
c=A
figure, imshow(c)
c1=0.9*A+0,1*B
figure, imshow(c1)
c2=0.8*A+0.2*B
figure, imshow(c2)
c3=0.7*A+0.3*B
figure, imshow(c3)
c4=0.6*A+0.4*B
figure, imshow(c4)
c5=0.5*A+0.5*B
figure, imshow(c5)
c6=0.4*A+0.6*B
figure, imshow(c6)
c7=0.3*A+0.7*B
figure, imshow(c7)
c8=0.2*A+0.8*B
figure, imshow(c8)
c9=0.1*A+0.9*B
figure, imshow(c9)
0 Comments
Answers (2)
KALYAN ACHARJYA
on 24 Mar 2019
Edited: KALYAN ACHARJYA
on 24 Mar 2019
It can be code like this. But I would like to write it down like loop, so it looks better.
I have chenged your code in for loop only.
clear all, close all
load('OBRAZKY/tvare.mat')
c=A;
j=0.1;
figure, imshow(c)
for i=0.9:-.1:.1
c=0.9*A+j*B;
figure, imshow(c)
j=j+0.1;
end
0 Comments
Image Analyst
on 24 Mar 2019
Try this:
s = load('OBRAZKY/tvare.mat')
A = s.A;
B = s.B;
% Define percentages that you want to blend.
percentages = 0 : 0.1 : 1;
plotRows = ceil(sqrt(length(percentages)));
for k = 1 : length(percentages)
% Get this percentage.
thisPct = percentages(k);
% Compute blended image.
ratioImage = (1 - thisPct) * double(A) + thisPct * double(B);
% Display image.
subplot(plotRows, plotRows, k);
imshow(ratioImage, [])
caption = sprintf('%.1f, %.1f', (1 - thisPct), thisPct);
title(caption);
end
Attach OBRAZKY/tvare.mat is you need more help.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!