改变图像部分的亮度和对比度(Changing brightness and contrast of portion of an image)
给定图像,我想改变图像部分的亮度/对比度。
我在这里使用一个例子来改变整个图像的亮度/对比度:
RNG rng(cv::getTickCount()); float min_alpha = 0.1; float max_alpha = 2.0; float alpha = rng.uniform(min_alpha, max_alpha); float beta = -2.0; image.convertTo(new_image, -1, alpha, beta);
有没有办法只在图像的子区域上执行此操作而无需在for循环中迭代整个图像?
Given an image, I'd like to change the brightness/contrast on portion of an image.
I'm using an example here to change the brightness/contrast of the whole image:
RNG rng(cv::getTickCount()); float min_alpha = 0.1; float max_alpha = 2.0; float alpha = rng.uniform(min_alpha, max_alpha); float beta = -2.0; image.convertTo(new_image, -1, alpha, beta);
Is there a way to do this only on a subregion of an image without having to iterate through the entire image on a for loop?
原文:https://stackoverflow.com/questions/43853560
最满意答案
变量的名称与列的名称相同。 通过MySQL的范围规则,该列正在与自身进行比较。
将存储过程中使用的所有变量添加到
v_
类是一个好习惯。 所以查询应该如下所示:UPDATE `imthreadmember` SET `lastUpdate`=CURRENT_TIMESTAMP WHERE `threadId` = v_threadId;
并且,作为推论,永远不要命名以
v_
开头的列。The name of your variable is the same as the name of the column. By MySQL's scoping rules, the column is being compared to itself.
It is a good habit to prepend all variables used in stored procedures with something like
v_
. So the query should look like:UPDATE `imthreadmember` SET `lastUpdate`=CURRENT_TIMESTAMP WHERE `threadId` = v_threadId;
And, as a corollary, to never name a column starting with
v_
.
相关问答
更多-
存储过程使用参数更新来自不同表的列名(Stored Procedure update with parameter a column name from a different table)[2022-05-14]
我认为这完成了你要做的事情,除了我已经删除了连接并在过程中声明了一个新变量,它根据用户输入的名称获取商店的ID。 然后它使用商店的ID更新表,即使用户没有输入商店ID(因为用户不知道这个,但系统会这样)。 当然,取决于你想要做什么,这仍然可能不起作用。 CREATE PROCEDURE spUpdateCustomerInformation @CustomerID int ,@StoreName varchar(50) AS BEGIN DECLARE @ID INT SELECT @ID = Stor ... -
您的更新语句应该是这样的: UPDATE PRODUCTS p SET p.P_QUANTITY = p.P_QUANTITY - qty WHERE p.PID = p_pid; --argument should have a different name than the column -- to keep it clean. 编辑 :请参阅@william Robertson的答案以获得详细解释。 Your update statement should probably be som ...
-
从存储过程中获取插入/更新/删除的行数 - Linq到SQL(Get inserted/updated/deleted rows count from stored procedure - Linq to SQL)[2021-07-14]
在存储过程中,您可以创建一个表变量(如果表变量不可用,则为临时表),并在影响表的行数的存储过程的每个部分之后将@@ rowcount插入其中,然后执行选择从表变量作为商店过程中的最后一个操作。 例如 CREATE PROCEDURE myProc AS BEGIN DECLARE @ra TABLE ( rowsAffected INT, queryName VARCHAR(50) ) INSERT INTO sometable SE ... -
如果我理解你的问题只是你所写的,你认为它做了什么? 我相信它确实如此。 您的更新看起来很好,但再次加入target.sku = source.sku是多余的。 单个合并语句中的所有不同语句(例如when matched , when not matched by source when not matched by target )将使用在顶部声明的连接条件,因此您无需再次指定它。 另一件需要考虑的事情是FlagValue是否为null。 如果是这样,检查target.FlagValue != source ...
-
我个人更喜欢将旧式技术用于通常所说的“upsert”。 MERGE运行良好,但调试问题真的很痛苦,因为它一次性完成所有工作。 这是我喜欢的方法类型,因为它将插入和更新分开,这提供了更大的灵活性并且更容易调试问题。 您还可以在插入中切换左连接以使用带有相关子查询的NOT EXISTS,但大多数时候性能差异可以忽略不计。 UPDATE t SET Name = a.Name, Timestamp = CONVERT(date, a.Timestamp), Data = AVG(a.Da ...
-
你可以这样做: DECLARE @InsertedValues TABLE (ID INT, City VARCHAR(50), State VARCHAR(50), Country VARCHAR(50)) INSERT INTO dbo.Location(City, State, Country) OUTPUT Inserted.ID, Inserted.City, Inserted.State, Inserted.Country INTO @InsertedValues(ID, City, St ...
-
如果我了解你的目标,这可能是查询: insert into dbo.myFinalTable select @theString as MyString, @id as MyId, @theDate as MyDate where not exists(select * from dbo.myFinalTable where MyId = @id and MyDate = @theDate) If I understood your g ...
-
变量的名称与列的名称相同。 通过MySQL的范围规则,该列正在与自身进行比较。 将存储过程中使用的所有变量添加到v_类是一个好习惯。 所以查询应该如下所示: UPDATE `imthreadmember` SET `lastUpdate`=CURRENT_TIMESTAMP WHERE `threadId` = v_threadId; 并且,作为推论,永远不要命名以v_开头的列。 The name of your variable is the same as the name of the co ...
-
为参数使用不同的名称: CREATE DEFINER=`root`@`localhost` PROCEDURE `update_location`( IN p_UID CHAR(17), IN p_lat FLOAT(10,6), IN p_lng FLOAT(10,6), IN p_country VARCHAR(3) ) BEGIN UPDATE location SET lat = p_lat, lng = p_lng, country = p_country ...
-
您可以使用表值参数( 这是一些信息) 首先创建表类型和SP: USE MyDB; GO -- Create a table type. CREATE TYPE SomeTableType AS TABLE ( SeqNum int, SeqDate datetime, Account_ID varchar(2) ); GO -- Create a procedure to receive data for the table-valued parameter ...