Comments (5)
the original problem was resolved in 8d369c1
from iga.
Well that's sort of odd, I can't see the email I just got through github...
Anyway, after patching iga to this state, I still get a scrambled output.
I think I fixed everything mentioned, but I could be wrong. And just as a sanity check, here's the message I got:
@flber
It's just that Love2d changed how it exposes image data in the meanwhile. img:getData() has been deprecated.
It's easy to fix. You just need to change this:
https://github.com/usysrc/iga/blob/964ab9f4123935949e2e393e047c7bec4eee18a4/main.lua#L7-L11
To this:
img_data = love.image.newImageData("input/input_10.png")
local ow, oh = 100,100
iga:geninit(img_data, ow,ow, img_data:getWidth(), img_data:getHeight(), 3)
And then in iga:geninit() make these three changes:
function iga:geninit(img_data, ow,oh,iw,ih,N_) -- line 42
[...]
-- remove this line (it's not needed anymore)
local data = img:getData() -- line 83
for i=0,input_width-1 do
for j=0,input_height-1 do
[...]
local r,g,b = img_data:getPixel(i,j) -- line 88
If I didn't forget anything, it should work now.
Although I should point out that for some odd reason this program has no way to quit or close. You can remove {borderless=true} from main.lua, and/or add a key to quit:
function love.keypressed(k)
if k == "escape" then love.event.quit() end
end
from iga.
@flber sorry, I deleted my reply because I thought I had totally misunderstood you (and probably did). At first I thought you'd be getting the error about img:getPixel()
, but then I noticed the algorithm in this port isn't working properly either. It's not producing the same results as the original. Re-reading your post after that made me think that that's what you meant, and not what I had interpreted before. I was under too much sleep deprivation to think, so I just deleted it hoping to avoid confusing you... :(
So yea, this is indeed not working properly, anyway. I tested it with the sample images from the original C# repo, and the results are also screwed up.
The original lua port seems to work fine, though, at least when running its own executable. I haven't tried porting it to love2d, but it might be worth looking into.
Again, sorry about the confusion.
from iga.
@Skaruts ah well, no problem
from iga.
@flber well I found the issue causing the scrambled output: colors have also been changed in love2d in the meanwhile. They use floats 0-1 now, and this was made when it used 0-255.
So to make this work better you only need to convert them:
-- iga.lua -- line 89: multiply components by 255
local colour = string.format("%03d%03d%03d",r*255,g*255,b*255)
-- main.lua -- line 26: convert back to floats, by diving them
love.graphics.setColor(tonumber(r)/255,tonumber(g)/255,tonumber(b)/255)
However, the results are still not looking like the original lua port. There are still black spots and plenty of artifacts. For example, the very first sample (a white cross) in the original port generates a straight grid, while this one generates a very disjointed resemblance of a grid.
EDIT: turns out, one part of the problem with the output is caused by line 239 being commented out
Lines 236 to 241 in 964ab9f
The other part of the problem is that uncommenting that line throws a stack overflow when testing sample_01, and possibly a few others. And the last part of the problem is that the original lua port is also screwed, to begin with. It handles its own samples well, but it fails with the original ones.
from iga.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iga.