libvips / nip2

A spreadsheet-like GUI for libvips.
https://libvips.github.io/libvips/
GNU General Public License v2.0
362 stars 13 forks source link

Has issues saving #107

Open Zireael07 opened 1 year ago

Zireael07 commented 1 year ago

Program saves as xml, but only wants to load .ws... Several hours of work went down the drain!

(Yes, I did succeed in making Scharr via convolutions tool, and I was in the process of figuring out how to combine stuff - you know, R channel from image X G from image Y B 0, when I must have clicked something nip didn't like and crashed)

Also: save as never produced a working image file, all of them were all black, even those that were RGB 0-255 according to nips

jcupitt commented 1 year ago

Oh no!

Try File / Recover -- nip2 saves the last 10 workspace edits in a recovery area, you should be able to get your work back.

Yes, .ws files are xml inside, but that shouldn't matter. Just save and load to myfile.ws or whatever and it'll all work.

I'll try assembling your demo images in nip2.

jcupitt commented 1 year ago

For a scharr filter in nip2, try saving this file as scahrr.def:

scharr image
    = (kx ** 2 + ky ** 2) ** 0.5
{
    scharr_matrix = Matrix [
        [ -3,   0,   3],
        [-10,   0,  10],
        [ -3,   0,   3]
    ];

    bw = (float) colour_transform_to Image_type.B_W image;
    kx = conv scharr_matrix bw;
    ky = conv (rot90 scharr_matrix) bw;
}

Start nip2, do Toolkits / Edit, then File / Open and load the .def file. A new toolkit should appear, called "scharr".

Load an image, then in the main window click Toolkits / scharr and it ought to work. I see:

image

jcupitt commented 1 year ago

I think you saw black because nip2 defaults to integer convolution. Cast your image to float before calling conv and it should work.

Alternatively you could also redo scharr as an int conv (perhaps add an offset of 128?).

Zireael07 commented 1 year ago

Try File / Recover -- nip2 saves the last 10 workspace edits in a recovery area, you should be able to get your work back.

Thanks, that worked. Attaching my file here so that you can take a look and figure out what is going wrong with save as for images themselves (and I still need a tip on that RGB combining thing - it's trivial in any other library I know but I can't figure it out here)

nipstest.zip

jcupitt commented 1 year ago

In nip2 it's image?band to get a band from an image, and image ++ image to join two images bandwise.

They work for strings and lists too, so:

"abc"?1 == "b"
"ab" ++ "c" == "abc"
[1..10]?4 == 5
[10..1]?8 == 2
[x ** 2 :: x <- [1..]]?100 == 10201

etc etc.

Zireael07 commented 1 month ago

Anything on the saving issue (both xml vs ws and the black image)? This effectively renders nip unusable

jcupitt commented 1 month ago

I think it works fine, doesn't it?

Workspace files are XML internally, but that shouldn't matter. Save as fred.ws, load back again, it should all work.

It shouldn't save black image files, you'll need to give a specific example I can check. What steps exactly did you follow, what format did you save in, etc.