Should I set a color space for a CIImage or a CIContext? - core-image

Core Image lets us specify a color space for a CIContext, as in:
let context = CIContext(options: [kCIContextOutputColorSpace: NSNull(),
kCIContextWorkingColorSpace: NSNull()])
Or for a CIImage, as in:
let image = CIImage(cvImageBuffer: inputPixelBuffer,
options: [kCIImageColorSpace: NSNull()])
How are these three related:
kCIContextOutputColorSpace
kCIContextWorkingColorSpace
kCIImageColorSpace
What are the pros and cons of setting each of them?

Related

Multiple variations of TKInter fonts

I am trying to get a better understanding of using fonts in tkinter and ttk.
My plan is to have two different styles for headings, each with their own font size. I used nametofont() to create an instance of the font and then set the size in two different styles:
labelFont = tkinter.font.nametofont('TkTextFont')
labelFont.config(weight='bold')
ttk.Style().configure("TLabel", font=labelFont, size=12)
ttk.Style().configure("heading.TLabel", font=labelFont, size=48)
then apply the styles to headings:
heading = ttk.Label(root, text="Heading", style="heading.TLabel")
label = ttk.Label(root, text="Label", style="TLabel") # is style redundant?
Unfortunately, I don’t get two different sizes, so this is obviously the wrong approach.
I also tried something like this:
labelFont = tkinter.font.nametofont('TkTextFont')
headingFont = tkinter.font.nametofont('TkTextFont')
# etc
thinking that I would get two independent instance of the font, but they appear to be the same instance. If they were independent, I could have used configure() to give each of them their own font size.
I took this approach because I wanted to use the built-in named font, and use variables to maintain consistency. What is the correct approach to this?
You need to use .config(size=...) on the different instances of Font:
labelFont = tkinter.font.nametofont('TkTextFont')
labelFont.config(weight='bold', size=12)
# create a clone of labelFont using Font.copy()
headingFont = labelFont.copy()
headingFont.config(size=48)
s = ttk.Style()
s.configure('TLabel', font=labelFont) # apply to all instance of ttk.Label
s.configure('heading.TLabel', font=headingFont, size=96)
heading = ttk.Label(root, text='Heading', style='heading.TLabel')
label = ttk.Label(root, text='Label') # style='TLabel' is not necessary

Understanding Vulkan uniform layout's 'set' index

I've been following along in the (very awesome) nvpro raytracing tutorial and have a question about the way the CameraProperties uniform buffer is bound using layout(binding = 0, set = 1) - I understand the binding = 0, but why set = 1?
The tutorial says "The set = 1 comes from the fact that it is the second descriptor set passed to pipelineLayoutCreateInfo.setPSetLayouts", but when I look at HelloVulkan::createGraphicsPipeline() I see the layout count is one, and this is where m_descSetLayout (what binds the camera uniform buffer) is used. What am I missing?
The related section of the tutorial is here.
Thanks!
See chapter 7.1:
std::vector<vk::DescriptorSetLayout> rtDescSetLayouts = {m_rtDescSetLayout, m_descSetLayout};
pipelineLayoutCreateInfo.setSetLayoutCount(static_cast<uint32_t>(rtDescSetLayouts.size()));
pipelineLayoutCreateInfo.setPSetLayouts(rtDescSetLayouts.data());
The pipeline layout contains two descriptor set layouts, m_rtDescSetLayout for the acceleration structures at index 0 (set 0) and m_descSetLayout for the screne descriptors in index 1 (set 1). In Vulkan the set is automatically derived from a descriptor set layout's index in the pipeline layouts create info.

I want segment the patches of size 32x32px or more using python's opencv

Here I have a image:
Then I have generated threshold image using the code below.
img = cv2.imread('Image_Original.jpg')
hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
lower_gr = np.array([40,0,0])
upper_gr = np.array([90,255,255])
mask = cv2.inRange(hsv,lower_gr,upper_gr)
mask=~mask
res = cv2.bitwise_and(img,img,mask = ~mask)
cv2.imshow('Masked',mask)
cv2.imshow('Result',res)
Then the following images (masked):
and (result):
Now what I want is to remove the black pixels(FROM THE ORiGINAL IMAGE ONLY) by making them zero and I want to extract only patches of size 32x32px or more.
Use cv2.findContours() to find the boundaries of the white patches in your mask image.
Each boundary is returned as a list of 2D points.
Use cv2.boundingRect() to get the width/height of each patch and filter accordingly.
You could also use cv2.minAreaRect(), or cv2.contourArea() to filter based on actual area of the patch.
https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.htm
Once you have determined which patches should be discarded, overwrite them with black on the colour image using cv2.fillPoly().

Material Components for IOS : MDCBottomAppBarView

I have checked around but no able to find any info about this.
Is there any way to set text and image in MDCBottomAppBarView, among setting the high of MDCBottomAppBarView ?
You can set the Image by setImage:
let appBarBottom = MDCBottomAppBarView()
appBarBottom.floatingButton.backgroundColor = UIColor.white // Change this if you have another color icon
appBarBottom.floatingButton.setImage(UIImage(named: "IMAGE NAME"), for: UIControl.State.normal)

Raphael js: animating path with it's drop shadow

I'm not sure how to fade in and out a path and the drop shadow I've created for it:
var p = "M10,10L810,10L810,190L10,190L10,10";
var s = "M16,16L816,16L816,196L16,196L16,16";
var paper = Raphael(100, 100, 830, 210);
var shadow = paper.path(s);
shadow.attr({stroke: "none", fill: "#999999", opacity:0.1});
shadow.blur(4);
var c = paper.path(p);
c.attr({fill:"#ffffff", stroke:"none"});
Do I have to manually animate c and shadow at the same time? Is there a way I can just tell this particular paper to fade everything inside of it?
put your path and your shadow in a set. apply your animation to the set and it'll affect both.
Here's a really terrible example where I move both at once.
Maybe animating the drop shadow path to match the specification of the other path?
http://www.irunmywebsite.com/raphael/additionalhelp.php?q=fadingdropshadow
the amadan answer is incorrect. please discard it.
If you put elements in a set, the glow will be part of the set but set is logical only.
it means that if you animate the set, your shadow animation will look wierd.
use set only to refer to logical zoning for events for instance.
best is to animate the shadows in // of the other objects.

Resources