Skip to content
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

Image transformers that do not use domain transformations #17

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

markotoplak
Copy link
Contributor

Some image transformation methods need the whole image because they do both parameter estimation (=learning) and actual transformation (using learned parameters) in a single operation. Therefore, when transforming, instances are not independent and thus this can not be solved with domain transformation in Orange.

Some image transformation methods need the whole image because they do
both parameter estimation (=learning) and actual transformation (using
learned parameters) in a single operation. Therefore, when transforming,
instances are not independent and thus this can not be solved with
domain transformation in Orange.
@markotoplak
Copy link
Contributor Author

@borondics and @ngergihun, does this solve problems due to chunking?

This is the "latter option" from yesterdays email - which I believe is actually the only possible solution for some methods and thus unavoidable.

@ngergihun
Copy link
Contributor

Hi @markotoplak !
It seems to work. The polynomial fit works just fine. However, the line leveling seems to do the leveling along the opposite direction of the image as expected. I think the data is reshaped in the opposite way than pySNOM transformer expects it.

Do you think, that this approach work for the referencing?

@markotoplak
Copy link
Contributor Author

markotoplak commented Oct 1, 2024

Yes, this approach would also work for references, with the only addition that the reference would need to get restructured in the same way.

@markotoplak
Copy link
Contributor Author

markotoplak commented Oct 1, 2024

@ngergihun, so what is the structure that pySNOM expects? If the first (numpys) axis Y or X?

@ngergihun
Copy link
Contributor

ngergihun commented Oct 1, 2024

@markotoplak if I swap the attr_x and attr_y in PreprocessImageOpts2DOnlyWhole like:

hypercube, _, indices = get_ndim_hyperspec(
                data, (image_opts["attr_y"], image_opts["attr_x"])
            )

Then it work all fine for me!

@markotoplak
Copy link
Contributor Author

@ngergihun, thanks for the comment, I fixed accordingly and added a comment about it.

@ngergihun
Copy link
Contributor

ngergihun commented Oct 1, 2024

@markotoplak in the meanwhile I tried to make the referencing work. Now it is a kind of very simple approach that I reashpe the reference.X to the same shape as the image from the data

class SelfRef(PreprocessImageOpts2DOnlyWhole):
    def __init__(self, reference):
        self.reference = reference.X

    def transform_image(self, image):
        self.reference = np.reshape(self.reference,np.shape(image))
        d = SelfReference(referencedata=self.reference).transform(image)
        return d

I don't know it is a good approach but for now, it works. Should I make a PR from that version at all?

@markotoplak
Copy link
Contributor Author

@ngergihun, can you open a PR with your modifications? Thanks!

What you suggest can't work in a general case. It probably works because the data in the table is ordered in just the right way (which is a tough assumption).

The same image reshaping operations as for the data will also have to be executed for the reference. I can do that part. what you can help me with is provide me the data where this works with your current modification, so it will be easier to ensure I did not break anything.

@ngergihun
Copy link
Contributor

Yes, I agree, that it is generally a bad solution and only work under very strict circumstances. I open the PR and send some data.

@ngergihun
Copy link
Contributor

@markotoplak Another thing came to my mind. So in the new PreprocessImageOpts2DOnlyWhole class the image is passed to the transform_image(self, image) method. When we reimplement the method in a preprocessor then we can access the reshaped image but cannot access the attributes of data where we store the datatype of the image data. Is there an easy solution, to also pass the attributes?

@markotoplak
Copy link
Contributor Author

@ngergihun, thanks for the comment. I'll add another parameter, data.

@markotoplak markotoplak merged commit 2ba9d1c into Quasars:master Oct 2, 2024
4 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants