specific transformation with tformarray
Show older comments
Hi, I want to displace specific pixel values in an image pixelwise. For example the below code takes a box of values 50 and moves them 16 pixels to the right. However I would like to move for example some fraction p from left to right, e.g. P=0.5 such that on the right the end values are sum of the old values and the new displaced intensities multiplied with 0.5. And that on the left location this transferred intensity is subtracted. For example here the left values would be 50*0.5 and right values 50*0.5 + 30 ... It seems this might be doable with tformarray but i dont seem to get it work any ideas?
Thank you very much!
clear
sphere = zeros(256,256);
[X,Y] = meshgrid(-127:128,-127:128);
[THETA,RHO] = cart2pol(X,Y);
sphere(RHO<50) = 50;
sphere(RHO<40) = 40;
sphere(RHO<30) = 30;
sphere(RHO<20) = 20;
Tx = zeros(size(sphere,1),size(sphere,2));
Ty = zeros(size(sphere));
Tx(126:130,100:104,1) = Tx(126:130,100:104,1) - 16;
[x y ]= meshgrid(1:size(sphere,1) ,1:size(sphere,2));
R = makeresampler('cubic','fill');
tmap_b = cat(3, Tx+x,y);
Iout = tformarray(sphere,[],R,[1 2],[1 2],[],tmap_b,0);
imtool(Iout,[])
clear RHO THETA X Y R tmap_b Ty Tx Int x y
Accepted Answer
More Answers (0)
Categories
Find more on Generic Geometric Transformations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!