YOUR ACCOUNT

Login or Register to post new topics or replies
xirja
Idididoll Forcabbage

Posts: 1698
Filters: 8
Trying to sort a gradient based on perceptual brightness and then selecting the darkest color.

The script included in the attachment does not give the expected result. Getting values from
the associative table doesn't seem to be working properly, as dark blue should be the result.

Most likely there is a problem with getting values from the table after the sort. a nil issue?

Any other ideas on how to use perceptual(Lab L) values to sort/reorder colors?

???

GradientTestDark.ffxml
_____________________________________________________

http://web.archive.org/web/2021062908...rjadesign/
_____________________________________________________
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
try this replacement:
Code
function get_sample(x, y)
   local c = {}
   for i = 1, 4 do
      c[i] = {}
      c[i].li = get_sample_grayscale(x, y, _G["I"..i])
      c[i].r,c[i].g,c[i].b,c[i].a = get_sample_map(x, y, _G["C"..i])
   end;
   local function compare(a,b)
      return (a.li < b.li)
   end
   table.sort(c, compare)
   return c[1].r, c[1].g, c[1].b, c[1].a
end;
  Details E-Mail
xirja
Idididoll Forcabbage

Posts: 1698
Filters: 8
Oh great, that _G["I"..i ] for multiple inputs! Thank you! It works, and much more elegantly than my baseball glove hands approach. smile:D

If there was a more general case of sorting a spectrum using OUTPUT_WIDTH though?

SpectrumTestCode.ffxml
_____________________________________________________

http://web.archive.org/web/2021062908...rjadesign/
_____________________________________________________
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,713 Registered Users
+19 new in 30 days!

153,537 Posts
+6 new in 7 days!

15,348 Topics
+72 new in year!

Create an Account

Online Users Last minute:

20 unregistered users.