How to mix two images in loop with 10%step.

2 Ansichten (letzte 30 Tage)
Michaela Syrovatkova
Michaela Syrovatkova am 24 Mär. 2019
Beantwortet: Image Analyst am 24 Mär. 2019
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)

Antworten (2)

KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Mär. 2019
Bearbeitet: KALYAN ACHARJYA am 24 Mär. 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

Image Analyst
Image Analyst am 24 Mär. 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
0001 Screenshot.png
Attach OBRAZKY/tvare.mat is you need more help.

Community Treasure Hunt

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

Start Hunting!

Translated by