Rank: 166036 based on 0 downloads (last 30 days) and 0 file submitted
photo

drdrb

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by drdrb View all
Updated File Comments Rating
22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Author: Jan Motl

% Also use this:

output = double(output(...
2:2:end-1,2:2:end-1));

% instead of this:

[height,width]=size(image);
height2=ceil(height/2);
width2=ceil(width/2);
height2l=floor(height/2);
width2l=floor(width/2);
matrix1=spalloc(height2,height,height2);
for j=1:height2l
matrix1(j,j*2)=1;
end
matrix2=spalloc(width,width2,width2);
for j=1:width2l
matrix2(j*2,j)=1;
end
output=matrix1*double(output)* matrix2;
output=output(1:end-1,1:end-1);

%sparse matrices are fancy, but just %avoiding "for" at any price(even %readability) can get you farther.

22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Author: Jan Motl

% Also use this:

output = double(output(...
2:2:end-1,2:2:end-1));

% istaid of this:

[height,width]=size(image);
height2=ceil(height/2);
width2=ceil(width/2);
height2l=floor(height/2);
width2l=floor(width/2);
matrix1=spalloc(height2,height,height2);
for j=1:height2l
matrix1(j,j*2)=1;
end
matrix2=spalloc(width,width2,width2);
for j=1:width2l
matrix2(j*2,j)=1;
end
output=matrix1*double(output)* matrix2;
output=output(1:end-1,1:end-1);

%sparse matrices are fancy, but just %avoiding "for" at any price(even %readability) can get you farther.

22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Author: Jan Motl

% Thank you!
% It's just what I was searching for!
% Great piece of code
% Just to note that this:

output=zeros(2*size(image));
output(2:2:end,2:2:end)=image;

% is much faster then this:

[height,width]=size(image);
matrix1=spalloc(2*height,height,height);
for i=1:height
matrix1(2*i,i)=1;%#ok
end
matrix2=spalloc(width,2*width,width);
for i=1:width
matrix2(i,2*i)=1;%#ok
end
output=matrix1*double(image)*matrix2;

Contact us