unni Posted October 13, 2018 Share Posted October 13, 2018 I am trying to understand how the maths is done for selections. Looks like it is done differently in AP, PS, GIMP etc. This difference is to be fully understood to have a predictable result when channel operations like add/subtract/intersect with pixel selections are done. Why this difference, I am unable to guess. Probably, some of it are for avoiding overflow errors or tackling it in different ways. Subtraction of a selection from itself: Result: For pixels between 0 to 127, nothing is done.Which means that the input and output pixels are same. For pixels from 128 to 255, output pixel is 255 minus input pixel. Addition and Intersection of a selection with itself: There is no change in pixels. This means no action is done. For intersection, I expected multiplication and for addition, increase in pixel values. A suggested method to verify the above: 1.Create a layer with circle patches of value 64, 127,128,129,192,255. 2.Cntrl+Shift+left click the layer.This selects pixels with marching ants on 50% or more bright area. 3.In the channels tab, keep cursor on pixel selection icon and right click to see create spare channel. 4.Create a spare channel. 5.Now keep cursor on the icon of this newly created spare channel and right click.From sub menu, select subtract from pixel selection. 6.Now do the subtraction. 7.The pixel selection now holds the subtracted result. 8.Go to layer tab and press on the white square with black circle icon to create a mask from this selection. 9.This mask now holds the result of the subtraction. 10.Create a pixel layer from this mask. 11.Using the info panel cursor, check the values of the circle patches to find out the change after the operation. 12.Do the above for addition and intersection at step 6. Any additional inputs on how the selection maths is done are welcome. Quote Link to comment Share on other sites More sharing options...
R C-R Posted October 14, 2018 Share Posted October 14, 2018 (edited) I am not sure I understand what you are asking about, but these operations are based on Boolean algebra, so all results must evaluate to true or false, or equivalently selected or not selected. Also note that "marching ants" pixel selections do not belong to any specific layer; they just define an area of selected pixels, so to speak. Edited October 14, 2018 by R C-R removed redundancy unni 1 Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
John Rostron Posted October 14, 2018 Share Posted October 14, 2018 I don't see that s appropriate or relevant to apply such boolean operations to pixel images. I am suprised that you were able to do so. I can see that a selection can be seen as a vector shape and that it may be appropriate to apply boolean operations to such shapes. It would seem to me that you should be able to apply boolean operations to monochrome masks. Is that what you are trying to do? John unni 1 Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
R C-R Posted October 14, 2018 Share Posted October 14, 2018 25 minutes ago, John Rostron said: I can see that a selection can be seen as a vector shape and that it may be appropriate to apply boolean operations to such shapes. Regardless of how you create them, "marching ants" selections are simply pixel selections enclosing a pixel area of a document. They are not part of any layer, although they can be derived from any layer, for example by the Mac CMD-click shortcut on a shape layer or with any of the selection tools on pixel layers. Because they are the result of boolean operations, their boundaries define whether individual pixels are included in or excluded from the selection -- there is no partial inclusion or exclusion. Because they are pixel selections, they can only be applied to pixel based (rasterized) objects like pixel layers or pixel masks, not resolution independent ones like vector shapes or text objects, unless they are first rasterized. unni and John Rostron 2 Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
Alfred Posted October 14, 2018 Share Posted October 14, 2018 17 hours ago, unni said: Subtraction of a selection from itself: Result: For pixels between 0 to 127, nothing is done.Which means that the input and output pixels are same. For pixels from 128 to 255, output pixel is 255 minus input pixel. Quote Create a layer with circle patches of value 64, 127,128,129,192,255. Are you referring to opacity, greyscale values, or something else? If the value 255 represents 100% opacity, please be aware that ‘marching ants’ will not be displayed around regions whose opacity is less than 50%. unni 1 Quote Alfred Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen) Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 I hope the details below will bring more clarity to what I have done. I tested with two methods. First by creating a white layer and painting hard circle patches with the input values of 0,64 etc. The color selector on the right top has to be used for selecting the exact value before creating the circle. The second test was done on a gradient layer which linearly increases from 0 to 255. Picking out values from gradient layer output is difficult but gradient result gives a nice visual clue on what is happening with these operations. The circle method gives the clue on the maths side of it, regressively. John Rostron 1 Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 PS Original gradient layer PS output after adding original with itself PS output after intersecting with itself PS output after subtracting with itself Quote Link to comment Share on other sites More sharing options...
R C-R Posted October 14, 2018 Share Posted October 14, 2018 48 minutes ago, unni said: First by creating a white layer and painting hard circle patches with the input values of 0,64 etc. Input values for what? Opacity, greyscale value, hue, saturation, lightness, red, blue, green, etc. are all possibilities, so please don't leave us guessing about that. EDIT: I also don't understand your 'selection with itself' table references. Since this uses boolean algebra there is only "x" if that is all that is selected. Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 AP Original Gradient layer AP output after adding original with itself AP output after intersecting with itself AP output after subtracting with itself Quote Link to comment Share on other sites More sharing options...
lepr Posted October 14, 2018 Share Posted October 14, 2018 . unni 1 Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 1 hour ago, R C-R said: Input values for what? Opacity, greyscale value, hue, saturation, lightness, red, blue, green, etc. are all possibilities, so please don't leave us guessing about that. @αℓƒяє∂ A new document is made from FILE>NEW>OK. I selected web type, 1280x800, RGB/8,ROMM RGB profile. Go to LAYER>NEW LAYER. Select paint brush OPACITY=HARDNESS=FLOW=100 Click on the two overlapping circle color chooser on right top under color tab. The color chooser rectangle box pops up. I see Hue inside the selectable tab. Enter same value for R,G,B. I entered 0, 64, etc to creat a greyscale brush of this desired value. So, the value thus selected is for the brush greyscale. Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 14 minutes ago, >|< said: A and B are in the floating point range 0 to 1 A add B: max(A, B) A subtract B: min(A, (1 - B)) A intersect B: min(A, B) This seems to explain what is happening in AP. So in the case of ADD and INTERSECT, no visual difference as A=B for every pixel. For SUBTRACT, the (1-B) term makes the difference even if A=B for every pixel. Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 1 hour ago, αℓƒяє∂ said: Are you referring to opacity, greyscale values, or something else? If the value 255 represents 100% opacity, please be aware that ‘marching ants’ will not be displayed around regions whose opacity is less than 50%. please see post 53 in this thread. I am unable to get your name popped up after writing the @ symbol in the post. The letters look different. Quote Link to comment Share on other sites More sharing options...
R C-R Posted October 14, 2018 Share Posted October 14, 2018 5 minutes ago, unni said: This seems to explain what is happening in AP. Please keep in mind that in Affinity these are boolean operations so no matter what or how you select anything using them, the result will just be a selection -- it has no color, greyness, lightness, etc. of its own. It just defines a pixel area. Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
walt.farrell Posted October 14, 2018 Share Posted October 14, 2018 10 minutes ago, unni said: please see post 53 in this thread. I am unable to get your name popped up after writing the @ symbol in the post. The letters look different. The first letter of his user name is a Greek alpha, so you must be able to type that character in order to mention him using @ in the forums. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 2 minutes ago, R C-R said: Please keep in mind that in Affinity these are boolean operations so no matter what or how you select anything using them, the result will just be a selection -- it has no color, greyness, lightness, etc. of its own. It just defines a pixel area. I understand this aspect but I was not able to figure out the formula of each operation. So had to do a sort of regressive experiment using gradients and solid patches to see what is happening and attempt to derive the relationship between the input and output pixels in all the three cases od add/sub/int. The fact that it is also different in PS,Gimp and AP still confused me because I expected all to be same like many other functions and tools. Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 1 minute ago, walt.farrell said: The first letter of his user name is a Greek alpha, so you must be able to type that character in order to mention him using @ in the forums. What is the key sequence please ?! Quote Link to comment Share on other sites More sharing options...
R C-R Posted October 14, 2018 Share Posted October 14, 2018 1 minute ago, unni said: What is the key sequence please ?! That depends on the OS, the keyboard, & the supported language(s). Also note that in these forums the numbers on the left below a member badge do not represent the post number in the topic. Instead the top number is the "Member's total reputation" (more or less the count of how many likes a member has received) & the lower one the total number of posts a member has made to all topics since joining the forums. unni 1 Quote All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7 Affinity Photo 1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7 Link to comment Share on other sites More sharing options...
John Rostron Posted October 14, 2018 Share Posted October 14, 2018 50 minutes ago, unni said: I am unable to get your name popped up after writing the @ symbol in the post. The letters look different. That is because Alfred chooses to be different and make life difficult for us ordinary mortals who use standard glyphs. John unni 1 Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 10 minutes ago, John Rostron said: That is because Alfred chooses to be different and make life difficult for us ordinary mortals who use standard glyphs. John found it !! - ALT+224 in the numeric pad (windows 7) John Rostron 1 Quote Link to comment Share on other sites More sharing options...
John Rostron Posted October 14, 2018 Share Posted October 14, 2018 1 minute ago, unni said: found it !! - ALT+224 in the numeric pad (windows 7) Yes, but why should we bother? John unni 1 Quote Windows 10, Affinity Photo 1.10.5 Designer 1.10.5 and Publisher 1.10.5 (mainly Photo), now ex-Adobe CC CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630 Link to comment Share on other sites More sharing options...
Alfred Posted October 14, 2018 Share Posted October 14, 2018 16 minutes ago, John Rostron said: Yes, but why should we bother? John You shouldn’t if you don’t want to, John! If you quote me, my awkward username will automatically come up in the title bar of the quote box, and if you reply to me I’ll see your post in the ‘Unread Content’ view (regardless of whether or not you mention me by name). unni and John Rostron 2 Quote Alfred Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen) Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 @αℓƒяє∂ : To minimize duplication of texts by way of "quote", I use the "@" method wherever possible. In some cases, "quote" is required and then I use it. Alfred 1 Quote Link to comment Share on other sites More sharing options...
lepr Posted October 14, 2018 Share Posted October 14, 2018 . unni 1 Quote Link to comment Share on other sites More sharing options...
unni Posted October 14, 2018 Author Share Posted October 14, 2018 @>|< : What you have posted earlier explains the results observed. Reproduced below between the two horizontal lines, again: As I understand, A is the luminosity of pixel of one layer and B that of corresponding pixel of the other layer. For this special case, A=B because operations are done on the selection with itself. ----------------------------------------------------------------------------------------------- A and B are in the floating point range 0 to 1 A add B: max(A, B) A subtract B: min(A, (1 - B)) A intersect B: min(A, B) ------------------------------------------------------------------------------------------------ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.