fatheral / matlab_imresize Goto Github PK
View Code? Open in Web Editor NEWPython implementation of MatLab imresize function
License: MIT License
Python implementation of MatLab imresize function
License: MIT License
According to https://stackoverflow.com/a/58363402/6065356 it's not enough to change the parameter in OpenCV since they use round
in contrast to MATLAB which uses ceil
to deduce the dimensions of the image. Anyways nice implementation which matches the MATLAB imresize
.
I read your article posted at https://www.reddit.com/r/MachineLearning/comments/6vdo51/p_matlab_bicubic_imresize_implemented_in_python/.
I totally agree with you that using matlab enforces off-line dataset building. (bad!!!)
You commented that "Note: it is not very optimized in terms of speed, and probably the best solution is to re-compile OpenCV (there single constant for cv::resize should be changed). But it is not always appropriate for all.", I have two questions with this one.
Thank you,
Hyunho.
I am using your code.
But i can not get the same psnr with matlab's.
This is my code (https://github.com/spnova12/get_set5_psnr)
If you do not mind, please check my code.
I also put the matlab code I used on github together.
since sometimes it is deprecated we can change the main file
import numpy as np
from scipy import ndimage
import matplotlib.pyplot as plt
from imresize import *
img_uint8 = ndimage.imread("test\\lena_512x512.png")
plt.figure()
plt.imshow(img_uint8)
new_size = (123, 234)
new_img_uint8 = imresize(img_uint8, output_shape=new_size)
plt.figure()
plt.imshow(new_img_uint8)
plt.show()
Thank you very much. :)
I was interested in using your library as it mimics Matlab's imresize perfectly, however I noticed that there was no license attached to the project/repo.
Github's default policy for this is (taken from https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository):
without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work
Have you considered adding a license so that others (including myself) can use your source code in our own projects?
Thanks!
My input image shape is [32,3,64,64], but the shape of result is [64,6,64,64] while it should be [32,3,128,128]
Did my modification cause it?
When I run the original code, a mistake happened: ValueError: operands could not be broadcast together with shapes (64,4,1,1) (64,4,3,64,64)
The mistake happens in the sentence: outimg = np.sum(weights*((inimg[indices].squeeze(axis=1)).astype(np.float64)), axis=1)
def imresizevec(inimg, weights, indices, dim):
wshape = weights.shape
if dim == 0:
weights = weights.reshape((wshape[0], wshape[2], 1, 1))
print(weights.shape)
outimg = np.sum(weights*((inimg[indices].squeeze(axis=1)).astype(np.float64)), axis=1)
print(outimg.shape)
So I change the "weights = weights.reshape((wshape[0], wshape[2], 1, 1))" to "weights = weights.reshape((wshape[0], wshape[2], 1, 1,1))"
Could you help me? Thanks a lot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.