-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a problem splitting the 512x512 px image into 64x64 px tiles #208
Comments
Hi @Nakilon, Would
|
If this is for training a NN, you can use the new It's not been added to ruby-vips yet, but should be pretty simple. |
Ah OK, yes, I'd think fetch would help a lot there. I would use fetch to get 16 columns and 16 rows of pixels so that you extract all the edges. Then chop into 64 pixel chunks and do a simple sum-of-squares-of-differences for every possible combination. Put that into a constraint solver and you should get the most likely answer. You're probably doing something very like this already. |
I made a branch with https://github.com/libvips/ruby-vips/tree/add-region-fetch You can run: it 'can fetch pixels from a region' do
image = Vips::Image.black(100, 100)
region = Vips::Region.new image
pixel_data = region.fetch 10, 20, 30, 40
expect(pixel_data)
expect(pixel_data.length == 30 * 40)
end The pixel data is a raw memory area, so it'll be RGBRGBRGB etc. bytes in your case. You could just get the green channel first to make it simpler. |
Heh, if only it was so easy to do it quickly like in Wolfram Mathematica, but not in my first experience of such with ruby-vips -- a lot of time is spent on directory traversing and filenames concatenations in my scripts. I just made score estimator on the example data to be sure I calculate results correctly, then had to wait until they fix server that stopped working for like an hour ..) The macOS Spotlight (4 processes in htop) goes mad after I process another folder for these tiles even while indexing is only enabled for Calculator, Programs and System Preferences. Oh, this |
Yes, file indexing is always annoying :( The first thing I turn off on a new Ubuntu.
|
Just to be sure I use the UPD: nvm, |
Is it ok? |
Yes, that's correct. A region is a persistent reference to a rectangular area of pixels in a virtual image. When you first create it, it has no memory attached to it. |
Glad it's working! |
The text was updated successfully, but these errors were encountered: